Skip to content

Commit 62020d2

Browse files
authored
Add various Behat tests (#2044)
1 parent b977b48 commit 62020d2

29 files changed

Lines changed: 397 additions & 234 deletions

.php-cs-fixer.dist.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
// fn => without curly brackets is less readable,
5959
// also prevent bounding of unwanted variables for GC
6060
'use_arrow_functions' => false,
61+
62+
'phpdoc_var_without_name' => false, // remove once https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/6962 is merged
6163
])
6264
->setFinder($finder)
6365
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache');

demos/_includes/DemoLookup.php

Lines changed: 0 additions & 67 deletions
This file was deleted.

demos/_unit-test/crud-nested.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
$crud->setModel($model);
1717

1818
$crud->addModalAction(['icon' => 'book'], 'Edit product category', function (View $v, $id) use ($model) {
19-
$entity = (clone $model)->load($id);
19+
$entity = $model->load($id);
2020

2121
$innerCrud = Crud::addTo($v);
2222
$innerCrud->setModel($entity->Products);

demos/collection/table.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@
6161
}
6262
});
6363

64-
$table->addTotals(['name' => 'Totals:', 'salary' => ['sum']]);
64+
$table->addTotals([
65+
'name' => 'Totals:',
66+
'salary' => ['sum'],
67+
]);
6568

6669
$myArray = [
6770
['name' => 'Vinny', 'surname' => 'Sihra', 'birthdate' => '1973-02-03', 'cv' => 'I am <strong>BIG</strong> Vinny'],

demos/collection/table2.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@
4949
});
5050

5151
$table->template->dangerouslyAppendHtml('Foot', $app->getTag('tr', ['class' => 'center aligned'], [['td', ['colspan' => '2'], 'This will appear above totals']]));
52-
$table->addTotals(['action' => 'Totals:', 'amount' => ['sum']]);
52+
$table->addTotals([
53+
'action' => 'Totals:',
54+
'amount' => ['sum'],
55+
]);
5356

5457
Header::addTo($app, ['Columns with multiple formats', 'subHeader' => 'Single column can use logic to swap out formatters', 'icon' => 'table']);
5558

demos/form-control/input2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
$model = new Country($app->db);
7777

7878
$group->addControl('Lookup_norm', [
79-
DemoLookup::class,
79+
Form\Control\Lookup::class,
8080
'model' => new Country($app->db),
8181
'plus' => true,
8282
])->set($model->loadAny()->getId());

demos/form-control/lookup-dep.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@
4747
}
4848
},
4949
'placeholder' => 'Selection depends on Dropdown above',
50-
'search' => [Country::hinting()->fieldName()->name, Country::hinting()->fieldName()->iso, Country::hinting()->fieldName()->iso3],
50+
'search' => [
51+
Country::hinting()->fieldName()->name,
52+
Country::hinting()->fieldName()->iso,
53+
Country::hinting()->fieldName()->iso3,
54+
],
5155
]);
5256

5357
$form->onSubmit(function (Form $form) {
@@ -79,7 +83,11 @@
7983
}
8084
},
8185
'multiple' => true,
82-
'search' => [Country::hinting()->fieldName()->name, Country::hinting()->fieldName()->iso, Country::hinting()->fieldName()->iso3],
86+
'search' => [
87+
Country::hinting()->fieldName()->name,
88+
Country::hinting()->fieldName()->iso,
89+
Country::hinting()->fieldName()->iso3,
90+
],
8391
]);
8492

8593
$form->onSubmit(function (Form $form) {

demos/form-control/lookup.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,23 @@
2929

3030
$model = new Model($app->db, ['table' => 'test']);
3131

32-
// Without Lookup
32+
// lookup without plus button
3333
$model->hasOne('country1', ['model' => [Country::class]]);
3434

35-
// With Lookup
36-
$model->hasOne('country2', ['model' => [Country::class], 'ui' => ['form' => [
37-
DemoLookup::class,
38-
'plus' => true,
39-
]]]);
35+
// lookup with plus button
36+
$model->hasOne('country2', ['model' => [Country::class], 'ui' => ['form' => ['plus' => true]]]);
4037

4138
$form->setModel($model->createEntity());
4239

4340
$form->addControl('country3', [
4441
Form\Control\Lookup::class,
4542
'model' => new Country($app->db),
4643
'placeholder' => 'Search for country by name or iso value',
47-
'search' => ['name', 'iso', 'iso3'],
44+
'search' => [
45+
Country::hinting()->fieldName()->name,
46+
Country::hinting()->fieldName()->iso,
47+
Country::hinting()->fieldName()->iso3,
48+
],
4849
]);
4950

5051
$form->onSubmit(function (Form $form) {

docs/js.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,10 @@ The following will **not** work::
513513
// JsModal requires its contents to be put into a Virtual Page
514514
$vp = \Atk4\Ui\VirtualPage::addTo($app);
515515
$form = \Atk4\Ui\Form::addTo($vp);
516-
$form->setModel(clone $model);
516+
$form->setModel($model);
517517

518518
$table = \Atk4\Ui\Table::addTo($app);
519-
$table->setModel(clone $model));
519+
$table->setModel($model));
520520

521521
$button = \Atk4\Ui\Button::addTo($app, ['Add Item', 'icon' => 'plus']);
522522
$button->on('click', new \Atk4\Ui\Js\JsModal('JSModal Title', $vp));
@@ -537,11 +537,11 @@ Table needs to be first! The following works::
537537

538538
// This needs to be first
539539
$table = \Atk4\Ui\Table::addTo($app);
540-
$table->setModel(clone $model));
540+
$table->setModel($model));
541541

542542
$vp = \Atk4\Ui\VirtualPage::addTo($app);
543543
$form = \Atk4\Ui\Form::addTo($vp);
544-
$form->setModel(clone $model);
544+
$form->setModel($model);
545545

546546
$button = \Atk4\Ui\Button::addTo($app, ['Add Item', 'icon' => 'plus']);
547547
$button->on('click', new \Atk4\Ui\Js\JsModal('JSModal Title', $vp));
@@ -566,7 +566,7 @@ VirtualPage content is rendered. To force yourself to put things in order you ca
566566
$vp = \Atk4\Ui\VirtualPage::addTo($app);
567567
$vp->set(function (\Atk4\Ui\VirtualPage $p) use ($table, $model) {
568568
$form = \Atk4\Ui\Form::addTo($p);
569-
$form->setModel(clone $model);
569+
$form->setModel($model);
570570
$form->onSubmit(function (Form $form) use ($table) {
571571
$form->model->save();
572572

phpstan.neon.dist

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ parameters:
125125
message: '~^Call to an undefined method Atk4\\Ui\\AbstractView&Atk4\\Ui\\UserAction\\ExecutorInterface::onHook\(\)\.$~'
126126
-
127127
path: 'src/Crud.php'
128-
message: '~^Call to an undefined method Atk4\\Ui\\UserAction\\JsExecutorInterface::stickyGet\(\)\.$~'
128+
message: '~^Call to an undefined method Atk4\\Ui\\AbstractView&Atk4\\Ui\\UserAction\\JsExecutorInterface::stickyGet\(\)\.$~'
129+
-
130+
path: 'src/Crud.php'
131+
message: '~^Call to an undefined method Atk4\\Ui\\AbstractView&Atk4\\Ui\\UserAction\\ExecutorInterface::onHook\(\)\.$~'
129132
-
130133
path: 'src/Form.php'
131134
message: '~^Call to an undefined method Atk4\\Ui\\AbstractView::addButton\(\)\.$~'
@@ -300,6 +303,9 @@ parameters:
300303
-
301304
path: 'src/CardDeck.php'
302305
message: '~^Property Atk4\\Ui\\CardDeck::\$paginator \(Atk4\\Ui\\Paginator\|false\|null\) does not accept Atk4\\Ui\\AbstractView\.$~'
306+
-
307+
path: 'src/Form/Control/Input.php'
308+
message: '~^Method Atk4\\Ui\\Form\\Control\\Input::prepareRenderButton\(\) should return Atk4\\Ui\\Button but returns \(Atk4\\Ui\\AbstractView&Atk4\\Ui\\UserAction\\ExecutorInterface\)\|Atk4\\Ui\\View\.$~'
303309
-
304310
path: 'src/Form/AbstractLayout.php'
305311
message: '~^Method Atk4\\Ui\\Form\\AbstractLayout::_addControl\(\) should return Atk4\\Ui\\Form\\Control but returns Atk4\\Ui\\View\.$~'

0 commit comments

Comments
 (0)