Skip to content

Commit 22246c8

Browse files
authored
Fix cb_view param type from #1671 (#1768)
1 parent e4d7912 commit 22246c8

15 files changed

+52
-61
lines changed

js/src/services/api.service.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class ApiService {
211211
* @param response
212212
*/
213213
onFailure(response) {
214-
// if json is returned, it should contains the error within message property
214+
// if json is returned, it should contain the error within message property
215215
if (Object.prototype.hasOwnProperty.call(response, 'success') && !response.success) {
216216
if (Object.prototype.hasOwnProperty.call(response, 'useWindow') && response.useWindow) {
217217
atk.apiService.showErrorWindow(response.message);

phpstan.neon.dist

-15
Original file line numberDiff line numberDiff line change
@@ -1535,9 +1535,6 @@ parameters:
15351535
-
15361536
path: 'src/JsReload.php'
15371537
message: '~^Method Atk4\\Ui\\JsReload::__construct\(\) has parameter \$view with no type specified\.$~'
1538-
-
1539-
path: 'src/JsSearch.php'
1540-
message: '~^Property Atk4\\Ui\\JsSearch::\$args has no type specified\.$~'
15411538
-
15421539
path: 'src/JsSearch.php'
15431540
message: '~^Property Atk4\\Ui\\JsSearch::\$filterIcon has no type specified\.$~'
@@ -1679,18 +1676,6 @@ parameters:
16791676
-
16801677
path: 'src/Modal.php'
16811678
message: '~^Property Atk4\\Ui\\Modal::\$headerCss has no type specified\.$~'
1682-
-
1683-
path: 'src/Modal.php'
1684-
message: '~^Property Atk4\\Ui\\Modal::\$fx has no type specified\.$~'
1685-
-
1686-
path: 'src/Modal.php'
1687-
message: '~^Property Atk4\\Ui\\Modal::\$cb has no type specified\.$~'
1688-
-
1689-
path: 'src/Modal.php'
1690-
message: '~^Property Atk4\\Ui\\Modal::\$cb_view has no type specified\.$~'
1691-
-
1692-
path: 'src/Modal.php'
1693-
message: '~^Property Atk4\\Ui\\Modal::\$args has no type specified\.$~'
16941679
-
16951680
path: 'src/Modal.php'
16961681
message: '~^Method Atk4\\Ui\\Modal::enableCallback\(\) has no return type specified\.$~'

src/Behat/Context.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function closeAllToasts(BeforeStepScope $event): void
4949
return;
5050
}
5151

52-
if (!str_starts_with($event->getStep()->getText(), 'Toast display should contains text ')) {
52+
if (!str_starts_with($event->getStep()->getText(), 'Toast display should contain text ')) {
5353
$this->getSession()->executeScript('jQuery(\'.toast-box > .ui.toast\').toast(\'close\');');
5454
}
5555
}
@@ -583,7 +583,7 @@ public function iScrollToTop(): void
583583
}
584584

585585
/**
586-
* @Then Toast display should contains text :arg1
586+
* @Then Toast display should contain text :arg1
587587
*/
588588
public function toastDisplayShouldContainText(string $text): void
589589
{
@@ -594,9 +594,9 @@ public function toastDisplayShouldContainText(string $text): void
594594
}
595595

596596
/**
597-
* @Then /^page url should contains \'([^\']*)\'$/
597+
* @Then /^page url should contain \'([^\']*)\'$/
598598
*/
599-
public function pageUrlShouldContains(string $text): void
599+
public function pageUrlShouldContain(string $text): void
600600
{
601601
$url = $this->getSession()->getCurrentUrl();
602602
if (!strpos($url, $text)) {
@@ -615,9 +615,9 @@ public function compareElementText(string $compareSelector, string $compareToSel
615615
}
616616

617617
/**
618-
* @Then /^text in container using \'([^\']*)\' should contains \'([^\']*)\'$/
618+
* @Then /^text in container using \'([^\']*)\' should contain \'([^\']*)\'$/
619619
*/
620-
public function textInContainerUsingShouldContains(string $selector, string $text): void
620+
public function textInContainerUsingShouldContain(string $selector, string $text): void
621621
{
622622
if (trim($this->getElementInPage($selector)->getText()) !== $text) {
623623
throw new Exception('Container with selector: ' . $selector . ' does not contain text: ' . $text);

src/JsSearch.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class JsSearch extends View
1313
/** @var View The View to reload using this JsSearch. */
1414
public $reload;
1515

16+
/** @var array */
1617
public $args = [];
1718

1819
/**

src/Modal.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ class Modal extends View
3636
public $loading_label = 'Loading...';
3737
public $headerCss = 'header';
3838
public $ui = 'modal';
39-
public $fx = [];
39+
/** @var \Closure|null */
40+
public $fx;
41+
/** @var CallbackLater|null */
4042
public $cb;
43+
/** @var View|null */
4144
public $cb_view;
45+
/** @var array */
4246
public $args = [];
4347
/** @var array */
4448
public $options = [];
@@ -80,7 +84,7 @@ public function set($fx = null, $ignore = null)
8084
throw new Exception('Only one argument is needed by Modal::set()');
8185
}
8286

83-
$this->fx = [$fx];
87+
$this->fx = $fx;
8488
$this->enableCallback();
8589

8690
return $this;
@@ -101,7 +105,7 @@ public function enableCallback()
101105
}
102106

103107
$this->cb->set(function () {
104-
$this->fx[0]($this->cb_view);
108+
($this->fx)($this->cb_view);
105109
$this->cb->terminateJson($this->cb_view);
106110
});
107111
}
@@ -301,7 +305,7 @@ protected function renderView(): void
301305
$this->template->trySet('contentCss', implode(' ', $this->contentCss));
302306
}
303307

304-
if (!empty($this->fx)) {
308+
if ($this->fx !== null) {
305309
$data['uri'] = $this->cb->getJsUrl();
306310
}
307311

src/Table/Column/ActionButtons.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Atk4\Ui\JsChain;
1111
use Atk4\Ui\Table;
1212
use Atk4\Ui\UserAction\ExecutorInterface;
13+
use Atk4\Ui\View;
1314

1415
/**
1516
* Formatting action buttons column.
@@ -33,10 +34,10 @@ protected function init(): void
3334
*
3435
* Returns button object
3536
*
36-
* @param \Atk4\Ui\View|string $button
37+
* @param View|string $button
3738
* @param JsChain|\Closure|ExecutorInterface $action
3839
*
39-
* @return \Atk4\Ui\View
40+
* @return View
4041
*/
4142
public function addButton($button, $action = null, string $confirmMsg = '', $isDisabled = false)
4243
{
@@ -47,7 +48,7 @@ public function addButton($button, $action = null, string $confirmMsg = '', $isD
4748
$button = [1 => $button];
4849
}
4950

50-
$button = Factory::factory([\Atk4\Ui\Button::class], Factory::mergeSeeds($button, ['id' => false]));
51+
$button = Factory::factory([Button::class], Factory::mergeSeeds($button, ['id' => false]));
5152
}
5253

5354
if ($isDisabled === true) {
@@ -71,12 +72,12 @@ public function addButton($button, $action = null, string $confirmMsg = '', $isD
7172
* Adds a new button which will open a modal dialog and dynamically
7273
* load contents through $callback. Will pass a virtual page.
7374
*
74-
* @param \Atk4\Ui\View|string $button
75-
* @param string|array $defaults modal title or modal defaults array
76-
* @param \Atk4\Ui\View $owner
77-
* @param array $args
75+
* @param View|string $button
76+
* @param string|array $defaults modal title or modal defaults array
77+
* @param View $owner
78+
* @param array $args
7879
*
79-
* @return \Atk4\Ui\View
80+
* @return View
8081
*/
8182
public function addModal($button, $defaults, \Closure $callback, $owner = null, $args = [])
8283
{
@@ -90,7 +91,7 @@ public function addModal($button, $defaults, \Closure $callback, $owner = null,
9091

9192
$modal->observeChanges(); // adds scrollbar if needed
9293

93-
$modal->set(function (\Atk4\Ui\Modal $t) use ($callback) {
94+
$modal->set(function (View $t) use ($callback) {
9495
$callback($t, $t->stickyGet($this->name));
9596
});
9697

tests-behat/basicexecutor.feature

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ Feature: Executor
44
Scenario: basic
55
Given I am on "data-action/actions.php"
66
And I press button "Import"
7-
Then Toast display should contains text "Done!"
7+
Then Toast display should contain text "Done!"
88

99
Scenario: form
1010
Given I am on "data-action/actions.php"
1111
And I press button "Run Import"
1212
Then I should see "Must not be empty"
1313
Then I fill in "path" with "."
1414
Then I press button "Run Import"
15-
Then Toast display should contains text "Imported!"
15+
Then Toast display should contain text "Imported!"
1616

1717
Scenario: preview
1818
Given I am on "data-action/actions.php"
1919
And I press button "Confirm"
20-
Then Toast display should contains text "Confirm!"
20+
Then Toast display should contain text "Confirm!"

tests-behat/callback.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Feature: Callback
66
Then I press button "First"
77
Then I should see "TestName"
88
And I press Modal button "Save"
9-
Then Toast display should contains text "Save"
9+
Then Toast display should contain text "Save"
1010
Then I should not see "TestName"
1111

1212
Scenario:
@@ -20,4 +20,4 @@ Feature: Callback
2020
Then I click first element using class ".ui.atk-test.button"
2121
Then Modal is open with text "Edit Country"
2222
Then I press Modal button "Save"
23-
Then Toast display should contains text "Form Submit"
23+
Then Toast display should contain text "Form Submit"

tests-behat/card.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ Feature: Card
77
Then Modal is open with text "Note" in tag "label"
88
When I fill in "note" with "This is a test note"
99
Then I press Modal button "Notify"
10-
Then Toast display should contains text "This is a test note"
10+
Then Toast display should contain text "This is a test note"

tests-behat/crud.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Feature: Crud
1313
# '50ce262c' = substr(md5('phonecode'), 0, 8)
1414
Then I fill in "atk_fp_country__50ce262c" with "1"
1515
Then I press Modal button "Save"
16-
Then Toast display should contains text "Form Submit"
16+
Then Toast display should contain text "Form Submit"
1717

1818
Scenario: search
1919
Then I search grid for "united kingdom"
@@ -23,7 +23,7 @@ Feature: Crud
2323
Then I press button "Edit"
2424
Then Modal is open with text "Edit Country"
2525
Then I press Modal button "Save"
26-
Then Toast display should contains text "Form Submit"
26+
Then Toast display should contain text "Form Submit"
2727
# make sure search query stick
2828
Then I should see "United Kingdom"
2929

tests-behat/grid.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Feature: Grid
66
Then I search grid for "kingdom"
77
Then I should see "United Kingdom"
88
Then I press button "Test"
9-
Then Toast display should contains text "United Kingdom"
9+
Then Toast display should contain text "United Kingdom"
1010
# click search remove icon
1111
Then I click icon using css "i.atk-remove-icon"
1212
Then I should not see "United Kingdom"
1313

1414
Scenario: search no ajax
1515
Given I am on "collection/grid.php?no-ajax=1"
1616
Then I search grid for "kingdom"
17-
Then page url should contains '_q=kingdom'
17+
Then page url should contain '_q=kingdom'
1818
Then I should see "United Kingdom"

tests-behat/lookup.feature

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ Feature: Lookup
99
# '6f3c91cf' = substr(md5('product_sub_category'), 0, 8)
1010
Then I select value "Yogourt" in lookup "atk_fp_product__6f3c91cf_id"
1111
Then I press modal button "Save"
12-
Then Toast display should contains text 'Dairy - Yogourt'
12+
Then Toast display should contain text 'Dairy - Yogourt'
1313

1414
Scenario: Testing lookup in VirtualPage
1515
Given I am on "_unit-test/lookup-virtual-page.php"
1616
Then I press menu button "Add Category" using class "atk-grid-menu"
1717
Then I select value "Beverages" in lookup "category"
1818
Then I press Modal button "Save"
19-
Then Toast display should contains text "Beverages"
19+
Then Toast display should contain text "Beverages"
2020

2121
Scenario: Testing lookup add
2222
Given I am on "form-control/lookup.php"
@@ -28,4 +28,4 @@ Feature: Lookup
2828
# '50ce262c' = substr(md5('phonecode'), 0, 8)
2929
When I fill in "atk_fp_country__50ce262c" with "8"
3030
Then I press Modal button "Save"
31-
Then Toast display should contains text "Form submit!"
31+
Then Toast display should contain text "Form submit!"

tests-behat/rightpanel.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Feature: RightPanel
1414
Then I click first card on page
1515
And I press button "User Confirmation"
1616
And I press Modal button "Ok"
17-
Then Toast display should contains text "Confirm country"
17+
Then Toast display should contain text "Confirm country"

tests-behat/useraction.feature

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ Feature: UserAction
44
Scenario:
55
Given I am on "data-action/jsactions2.php"
66
And I press button "Callback"
7-
Then Toast display should contains text "callback execute using country"
7+
Then Toast display should contain text "callback execute using country"
88

99
Scenario:
1010
And I press button "Argument"
1111
Then Modal is open with text "Age" in tag "label"
1212
When I fill Modal field "age" with "22"
1313
Then I press Modal button "Argument"
14-
Then Toast display should contains text "22 is old enough to visit"
14+
Then Toast display should contain text "22 is old enough to visit"
1515

1616
Scenario:
1717
And I press button "User Confirmation"
1818
And I press Modal button "Ok"
19-
Then Toast display should contains text "Confirm country"
19+
Then Toast display should contain text "Confirm country"
2020

2121
Scenario:
2222
And I press button "Multi Step"
@@ -26,7 +26,7 @@ Feature: UserAction
2626
Then I press Modal button "Next"
2727
Then Modal is open with text "Gender = m / Age = 22"
2828
Then I press Modal button "Multi Step"
29-
Then Toast display should contains text "Thank you Mr. at age 22"
29+
Then Toast display should contain text "Thank you Mr. at age 22"
3030

3131
Scenario: testing VpExecutor
3232
Given I am on "data-action/jsactions-vp.php"
@@ -56,7 +56,7 @@ Feature: UserAction
5656
Then Panel is open with text "Age" in tag "label"
5757
When I fill Panel field "age" with "22"
5858
Then I press Panel button "Argument"
59-
Then Toast display should contains text "22 is old enough to visit"
59+
Then Toast display should contain text "22 is old enough to visit"
6060

6161
Scenario: testing multi in panel
6262
And I press button "Multi Step"
@@ -66,4 +66,4 @@ Feature: UserAction
6666
Then I press Panel button "Next"
6767
Then Panel is open with text "Gender = m / Age = 22"
6868
Then I press Panel button "Multi Step"
69-
Then Toast display should contains text "Thank you Mr. at age 22"
69+
Then Toast display should contain text "Thank you Mr. at age 22"

tests-behat/virtual-page.feature

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Feature: VirtualPage
33
Scenario:
44
Given I am on "interactive/virtual.php"
55
Then I click link 'More info on Car'
6-
Then text in container using '.__atk-behat-test-car' should contains 'Car'
6+
Then text in container using '.__atk-behat-test-car' should contain 'Car'
77
Then I press button "Open Lorem Ipsum"
88
Then Modal is open with text 'This is yet another modal'
99

@@ -15,16 +15,16 @@ Feature: VirtualPage
1515
Scenario:
1616
Given I am on "interactive/virtual.php"
1717
Then I click link 'Inside current layout'
18-
Then text in container using '.__atk-behat-test-content' should contains 'Contents of your pop-up here'
18+
Then text in container using '.__atk-behat-test-content' should contain 'Contents of your pop-up here'
1919

2020
Scenario:
2121
Given I am on "_unit-test/virtual-page.php"
2222
Then I click link 'Open First'
23-
Then text in container using '.__atk-behat-test-first' should contains 'First Level Page'
23+
Then text in container using '.__atk-behat-test-first' should contain 'First Level Page'
2424
Then I click link 'Open Second'
25-
Then text in container using '.__atk-behat-test-second' should contains 'Second Level Page'
25+
Then text in container using '.__atk-behat-test-second' should contain 'Second Level Page'
2626
Then I click link 'Open Third'
27-
Then text in container using '.__atk-behat-test-third' should contains 'Third Level Page'
27+
Then text in container using '.__atk-behat-test-third' should contain 'Third Level Page'
2828
Then I select value "Beverages" in lookup "category"
2929
Then I press button "Save"
30-
Then Toast display should contains text 'Beverages'
30+
Then Toast display should contain text 'Beverages'

0 commit comments

Comments
 (0)