Skip to content

Commit 05d1fde

Browse files
authored
Do not mutate App::$request during testing (#2111)
1 parent 1d6804f commit 05d1fde

File tree

152 files changed

+888
-789
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+888
-789
lines changed

demos/_unit-test/sse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$v = View::addTo($app)->set('This will trigger a network request for testing SSE...');
1616

1717
$sse = JsSse::addTo($app);
18-
// URL trigger must match php_unit test in sse provider.
18+
// URL trigger must match phpunit test in SSE provider
1919
$sse->setUrlTrigger('see_test');
2020

2121
$v->js(true, $sse->set(static function () use ($sse) {

demos/basic/button.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@
1515
/** @var \Atk4\Ui\App $app */
1616
require_once __DIR__ . '/../init-app.php';
1717

18-
// Demonstrates how to use buttons.
19-
2018
Header::addTo($app, ['Basic Button', 'size' => 2]);
2119

22-
// With Seed
20+
// with seed
2321
Button::addTo($app, ['Click me'])->link(['index']);
2422

25-
// Without Seeding
23+
// without seeding
2624
$b1 = new Button('Click me (no seed)');
2725
$app->add($b1);
2826
// must be added first

demos/collection/card-deck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
]);
2929

30-
// Create custom button for this action in card.
30+
// create custom button for this action in card
3131
$app->getExecutorFactory()->registerTrigger(ExecutorFactory::CARD_BUTTON, [Button::class, 'class.blue' => true, 'icon' => 'plane'], $action);
3232

3333
$action->args = [

demos/collection/crud.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
$crud = Crud::addTo($app, ['ipp' => 10]);
2424

25-
// callback for model action add form.
25+
// callback for model action add form
2626
$crud->onFormAdd(static function (Form $form, ModalExecutor $ex) use ($model) {
2727
$form->js(true, $form->getControl($model->fieldName()->name)->jsInput()->val('Entering value via javascript'));
2828
});
2929

30-
// callback for model action edit form.
30+
// callback for model action edit form
3131
$crud->onFormEdit(static function (Form $form) use ($model) {
3232
$form->js(true, $form->getControl($model->fieldName()->name)->jsInput()->attr('readonly', true));
3333
});
@@ -51,7 +51,7 @@
5151
'menu' => ['class' => ['green inverted']],
5252
'table' => ['class' => ['red inverted']],
5353
]);
54-
// Condition on the model can be applied on a model
54+
// condition on the model can be applied on a model
5555
$model = new Country($app->db);
5656
$model->addCondition($model->fieldName()->numcode, '<', 200);
5757
$model->onHook(Model::HOOK_VALIDATE, static function (Country $model, ?string $intent) {
@@ -64,7 +64,7 @@
6464
});
6565
$crud->setModel($model);
6666

67-
// Because Crud inherits Grid, you can also define custom actions
67+
// because Crud inherits Grid, you can also define custom actions
6868
$crud->addModalAction(['icon' => 'cogs'], 'Details', static function (View $p, $id) use ($crud) {
6969
$model = Country::assertInstanceOf($crud->model);
7070
Message::addTo($p, ['Details for: ' . $model->load($id)->name . ' (id: ' . $id . ')']);
@@ -102,6 +102,6 @@ public function addFormTo(View $view): Form
102102

103103
$crud->menu->addItem(['Rescan', 'icon' => 'recycle']);
104104

105-
// Condition on the model can be applied after setting the model
105+
// condition on the model can be applied after setting the model
106106
$crud->setModel($file);
107107
$file->addCondition($file->fieldName()->parent_folder_id, null);

demos/collection/crud3.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function init(): void
2727
}
2828
});
2929

30-
// Prepare Persistence and data Model
30+
// prepare Persistence and data Model
3131
$data = ['test' => [
3232
1 => ['id' => 1, 'name' => 'ABC9', 'code' => 11, 'country' => 'Ireland'],
3333
2 => ['id' => 2, 'name' => 'ABC8', 'code' => 12, 'country' => 'Ireland'],

demos/collection/grid.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
'nameField' => $model->fieldName()->name,
3737
]);
3838

39-
// Adding Quicksearch on Name field using auto query.
39+
// adding Quicksearch on Name field using auto query
4040
$grid->addQuickSearch([$model->fieldName()->name], true);
4141

4242
if ($grid->stickyGet('no-ajax')) {
@@ -49,7 +49,7 @@
4949

5050
$grid->addColumn(null, [Table\Column\Template::class, 'hello<b>world</b>']);
5151

52-
// Creating a button for executing model test user action.
52+
// creating a button for executing model test user action
5353
$grid->addExecutorButton($grid->getExecutorFactory()->createExecutor($model->getUserAction('test'), $grid));
5454

5555
$grid->addActionButton('Say HI', static function (Jquery $j, $id) use ($grid) {
@@ -62,7 +62,7 @@
6262
Message::addTo($p, ['Clicked on ID=' . $id]);
6363
});
6464

65-
// Creating an executor for delete action.
65+
// creating an executor for delete action
6666
$deleteExecutor = $grid->getExecutorFactory()->createExecutor($model->getUserAction('delete'), $grid);
6767
$deleteExecutor->onHook(BasicExecutor::HOOK_AFTER_EXECUTE, static function () {
6868
return [
@@ -79,7 +79,7 @@
7979
return new JsToast('Selected: ' . implode(', ', $ids) . '#');
8080
});
8181

82-
// Executing a modal on a bulk selection
82+
// executing a modal on a bulk selection
8383
$grid->addModalBulkAction(['Delete selected', 'icon' => 'trash'], '', static function (View $modal, array $ids) use ($grid) {
8484
Message::addTo($modal, [
8585
'The selected records will be permanently deleted: ' . implode(', ', $ids) . '#',
@@ -103,5 +103,5 @@
103103
});
104104
});
105105

106-
// Setting ipp with an array will add an ItemPerPageSelector to paginator.
106+
// setting ipp with an array will add an ItemPerPageSelector to paginator
107107
$grid->setIpp([10, 100, 1000]);

demos/collection/multitable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/** @var \Atk4\Ui\App $app */
1818
require_once __DIR__ . '/../init-app.php';
1919

20-
// Re-usable component implementing counter
20+
// re-usable component implementing counter
2121

2222
$finderClass = AnonymousClassNameCache::get_class(fn () => new class() extends Columns {
2323
public array $route = [];

demos/collection/tablecolumnmenu.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
Header::addTo($app, ['Table column may contains popup or dropdown menu.']);
1818

19-
// Better Popup positioning when Popup are inside a container.
19+
// better Popup positioning when Popup are inside a container
2020
$container = View::addTo($app, ['ui' => 'vertical segment']);
2121
$table = Table::addTo($container, ['class.celled' => true]);
2222
$table->setModel(new SomeData(), []);
2323

24-
// will add popup to this column.
24+
// will add popup to this column
2525
$colName = $table->addColumn('name');
2626

27-
// will add dropdown menu to this column.
27+
// will add dropdown menu to this column
2828
$colSurname = $table->addColumn('surname');
2929

3030
$colTitle = $table->addColumn('title');
@@ -36,7 +36,7 @@
3636
Text::addTo($colName->addPopup())->set('Name popup');
3737

3838
// dynamic popup setup
39-
// This popup will add content using the callback function.
39+
// this popup will add content using the callback function
4040
$colSurname->addPopup()->set(static function (View $pop) {
4141
Text::addTo($pop)->set('This popup is loaded dynamically');
4242
});
@@ -50,16 +50,16 @@
5050

5151
Header::addTo($app, ['Grid column may contains popup or dropdown menu.']);
5252

53-
// Table in Grid are already inside a container.
53+
// Table in Grid are already inside a container
5454
$grid = Grid::addTo($app);
5555
$grid->setModel(new Country($app->db));
5656
$grid->ipp = 5;
5757

58-
// Adding a dropdown menu to the column 'name'.
58+
// adding a dropdown menu to the column 'name'
5959
$grid->addDropdown(Country::hinting()->fieldName()->name, ['Rename', 'Delete'], static function (string $item) {
6060
return $item;
6161
});
6262

63-
// Adding a popup view to the column 'iso'
63+
// adding a popup view to the column 'iso'
6464
$pop = $grid->addPopup(Country::hinting()->fieldName()->iso);
6565
Text::addTo($pop)->set('Grid column popup');

demos/collection/tablefilter.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
/** @var \Atk4\Ui\App $app */
1111
require_once __DIR__ . '/../init-app.php';
1212

13-
// For popup positioning to work correctly, table needs to be inside a view segment.
13+
// for popup positioning to work correctly, table needs to be inside a view segment
1414
$view = View::addTo($app, ['ui' => 'basic segment']);
15-
// Important: menu class added for Behat testing.
16-
$grid = Grid::addTo($view, ['menu' => ['class' => ['atk-grid-menu']]]);
15+
$grid = Grid::addTo($view, ['menu' => ['class' => ['atk-grid-menu']]]); // menu class added for Behat testing
1716

1817
$model = new Country($app->db);
1918
$model->addExpression('is_uk', [

demos/data-action/actions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// Which fields may be edited for the action. Default to all fields.
2323
// ModalExecutor for example, will only display fields set in this array.
2424
'fields' => [$files->fieldName()->name],
25-
// callback function to call in model when action execute.
25+
// Callback function to call in model when action execute.
2626
// Can use a closure function or model method.
2727
'callback' => 'importFromFilesystem',
2828
// Some Ui action executor will use this property for displaying text in button.

0 commit comments

Comments
 (0)