Skip to content

Commit

Permalink
Fix cb_view param type from #1671 (#1768)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek authored Apr 9, 2022
1 parent e4d7912 commit 22246c8
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 61 deletions.
2 changes: 1 addition & 1 deletion js/src/services/api.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class ApiService {
* @param response
*/
onFailure(response) {
// if json is returned, it should contains the error within message property
// if json is returned, it should contain the error within message property
if (Object.prototype.hasOwnProperty.call(response, 'success') && !response.success) {
if (Object.prototype.hasOwnProperty.call(response, 'useWindow') && response.useWindow) {
atk.apiService.showErrorWindow(response.message);
Expand Down
15 changes: 0 additions & 15 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -1535,9 +1535,6 @@ parameters:
-
path: 'src/JsReload.php'
message: '~^Method Atk4\\Ui\\JsReload::__construct\(\) has parameter \$view with no type specified\.$~'
-
path: 'src/JsSearch.php'
message: '~^Property Atk4\\Ui\\JsSearch::\$args has no type specified\.$~'
-
path: 'src/JsSearch.php'
message: '~^Property Atk4\\Ui\\JsSearch::\$filterIcon has no type specified\.$~'
Expand Down Expand Up @@ -1679,18 +1676,6 @@ parameters:
-
path: 'src/Modal.php'
message: '~^Property Atk4\\Ui\\Modal::\$headerCss has no type specified\.$~'
-
path: 'src/Modal.php'
message: '~^Property Atk4\\Ui\\Modal::\$fx has no type specified\.$~'
-
path: 'src/Modal.php'
message: '~^Property Atk4\\Ui\\Modal::\$cb has no type specified\.$~'
-
path: 'src/Modal.php'
message: '~^Property Atk4\\Ui\\Modal::\$cb_view has no type specified\.$~'
-
path: 'src/Modal.php'
message: '~^Property Atk4\\Ui\\Modal::\$args has no type specified\.$~'
-
path: 'src/Modal.php'
message: '~^Method Atk4\\Ui\\Modal::enableCallback\(\) has no return type specified\.$~'
Expand Down
12 changes: 6 additions & 6 deletions src/Behat/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function closeAllToasts(BeforeStepScope $event): void
return;
}

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

/**
* @Then Toast display should contains text :arg1
* @Then Toast display should contain text :arg1
*/
public function toastDisplayShouldContainText(string $text): void
{
Expand All @@ -594,9 +594,9 @@ public function toastDisplayShouldContainText(string $text): void
}

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

/**
* @Then /^text in container using \'([^\']*)\' should contains \'([^\']*)\'$/
* @Then /^text in container using \'([^\']*)\' should contain \'([^\']*)\'$/
*/
public function textInContainerUsingShouldContains(string $selector, string $text): void
public function textInContainerUsingShouldContain(string $selector, string $text): void
{
if (trim($this->getElementInPage($selector)->getText()) !== $text) {
throw new Exception('Container with selector: ' . $selector . ' does not contain text: ' . $text);
Expand Down
1 change: 1 addition & 0 deletions src/JsSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class JsSearch extends View
/** @var View The View to reload using this JsSearch. */
public $reload;

/** @var array */
public $args = [];

/**
Expand Down
12 changes: 8 additions & 4 deletions src/Modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ class Modal extends View
public $loading_label = 'Loading...';
public $headerCss = 'header';
public $ui = 'modal';
public $fx = [];
/** @var \Closure|null */
public $fx;
/** @var CallbackLater|null */
public $cb;
/** @var View|null */
public $cb_view;
/** @var array */
public $args = [];
/** @var array */
public $options = [];
Expand Down Expand Up @@ -80,7 +84,7 @@ public function set($fx = null, $ignore = null)
throw new Exception('Only one argument is needed by Modal::set()');
}

$this->fx = [$fx];
$this->fx = $fx;
$this->enableCallback();

return $this;
Expand All @@ -101,7 +105,7 @@ public function enableCallback()
}

$this->cb->set(function () {
$this->fx[0]($this->cb_view);
($this->fx)($this->cb_view);
$this->cb->terminateJson($this->cb_view);
});
}
Expand Down Expand Up @@ -301,7 +305,7 @@ protected function renderView(): void
$this->template->trySet('contentCss', implode(' ', $this->contentCss));
}

if (!empty($this->fx)) {
if ($this->fx !== null) {
$data['uri'] = $this->cb->getJsUrl();
}

Expand Down
19 changes: 10 additions & 9 deletions src/Table/Column/ActionButtons.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Atk4\Ui\JsChain;
use Atk4\Ui\Table;
use Atk4\Ui\UserAction\ExecutorInterface;
use Atk4\Ui\View;

/**
* Formatting action buttons column.
Expand All @@ -33,10 +34,10 @@ protected function init(): void
*
* Returns button object
*
* @param \Atk4\Ui\View|string $button
* @param View|string $button
* @param JsChain|\Closure|ExecutorInterface $action
*
* @return \Atk4\Ui\View
* @return View
*/
public function addButton($button, $action = null, string $confirmMsg = '', $isDisabled = false)
{
Expand All @@ -47,7 +48,7 @@ public function addButton($button, $action = null, string $confirmMsg = '', $isD
$button = [1 => $button];
}

$button = Factory::factory([\Atk4\Ui\Button::class], Factory::mergeSeeds($button, ['id' => false]));
$button = Factory::factory([Button::class], Factory::mergeSeeds($button, ['id' => false]));
}

if ($isDisabled === true) {
Expand All @@ -71,12 +72,12 @@ public function addButton($button, $action = null, string $confirmMsg = '', $isD
* Adds a new button which will open a modal dialog and dynamically
* load contents through $callback. Will pass a virtual page.
*
* @param \Atk4\Ui\View|string $button
* @param string|array $defaults modal title or modal defaults array
* @param \Atk4\Ui\View $owner
* @param array $args
* @param View|string $button
* @param string|array $defaults modal title or modal defaults array
* @param View $owner
* @param array $args
*
* @return \Atk4\Ui\View
* @return View
*/
public function addModal($button, $defaults, \Closure $callback, $owner = null, $args = [])
{
Expand All @@ -90,7 +91,7 @@ public function addModal($button, $defaults, \Closure $callback, $owner = null,

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

$modal->set(function (\Atk4\Ui\Modal $t) use ($callback) {
$modal->set(function (View $t) use ($callback) {
$callback($t, $t->stickyGet($this->name));
});

Expand Down
6 changes: 3 additions & 3 deletions tests-behat/basicexecutor.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ Feature: Executor
Scenario: basic
Given I am on "data-action/actions.php"
And I press button "Import"
Then Toast display should contains text "Done!"
Then Toast display should contain text "Done!"

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

Scenario: preview
Given I am on "data-action/actions.php"
And I press button "Confirm"
Then Toast display should contains text "Confirm!"
Then Toast display should contain text "Confirm!"
4 changes: 2 additions & 2 deletions tests-behat/callback.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: Callback
Then I press button "First"
Then I should see "TestName"
And I press Modal button "Save"
Then Toast display should contains text "Save"
Then Toast display should contain text "Save"
Then I should not see "TestName"

Scenario:
Expand All @@ -20,4 +20,4 @@ Feature: Callback
Then I click first element using class ".ui.atk-test.button"
Then Modal is open with text "Edit Country"
Then I press Modal button "Save"
Then Toast display should contains text "Form Submit"
Then Toast display should contain text "Form Submit"
2 changes: 1 addition & 1 deletion tests-behat/card.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Feature: Card
Then Modal is open with text "Note" in tag "label"
When I fill in "note" with "This is a test note"
Then I press Modal button "Notify"
Then Toast display should contains text "This is a test note"
Then Toast display should contain text "This is a test note"
4 changes: 2 additions & 2 deletions tests-behat/crud.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Feature: Crud
# '50ce262c' = substr(md5('phonecode'), 0, 8)
Then I fill in "atk_fp_country__50ce262c" with "1"
Then I press Modal button "Save"
Then Toast display should contains text "Form Submit"
Then Toast display should contain text "Form Submit"

Scenario: search
Then I search grid for "united kingdom"
Expand All @@ -23,7 +23,7 @@ Feature: Crud
Then I press button "Edit"
Then Modal is open with text "Edit Country"
Then I press Modal button "Save"
Then Toast display should contains text "Form Submit"
Then Toast display should contain text "Form Submit"
# make sure search query stick
Then I should see "United Kingdom"

Expand Down
4 changes: 2 additions & 2 deletions tests-behat/grid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Feature: Grid
Then I search grid for "kingdom"
Then I should see "United Kingdom"
Then I press button "Test"
Then Toast display should contains text "United Kingdom"
Then Toast display should contain text "United Kingdom"
# click search remove icon
Then I click icon using css "i.atk-remove-icon"
Then I should not see "United Kingdom"

Scenario: search no ajax
Given I am on "collection/grid.php?no-ajax=1"
Then I search grid for "kingdom"
Then page url should contains '_q=kingdom'
Then page url should contain '_q=kingdom'
Then I should see "United Kingdom"
6 changes: 3 additions & 3 deletions tests-behat/lookup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Feature: Lookup
# '6f3c91cf' = substr(md5('product_sub_category'), 0, 8)
Then I select value "Yogourt" in lookup "atk_fp_product__6f3c91cf_id"
Then I press modal button "Save"
Then Toast display should contains text 'Dairy - Yogourt'
Then Toast display should contain text 'Dairy - Yogourt'

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

Scenario: Testing lookup add
Given I am on "form-control/lookup.php"
Expand All @@ -28,4 +28,4 @@ Feature: Lookup
# '50ce262c' = substr(md5('phonecode'), 0, 8)
When I fill in "atk_fp_country__50ce262c" with "8"
Then I press Modal button "Save"
Then Toast display should contains text "Form submit!"
Then Toast display should contain text "Form submit!"
2 changes: 1 addition & 1 deletion tests-behat/rightpanel.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Feature: RightPanel
Then I click first card on page
And I press button "User Confirmation"
And I press Modal button "Ok"
Then Toast display should contains text "Confirm country"
Then Toast display should contain text "Confirm country"
12 changes: 6 additions & 6 deletions tests-behat/useraction.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ Feature: UserAction
Scenario:
Given I am on "data-action/jsactions2.php"
And I press button "Callback"
Then Toast display should contains text "callback execute using country"
Then Toast display should contain text "callback execute using country"

Scenario:
And I press button "Argument"
Then Modal is open with text "Age" in tag "label"
When I fill Modal field "age" with "22"
Then I press Modal button "Argument"
Then Toast display should contains text "22 is old enough to visit"
Then Toast display should contain text "22 is old enough to visit"

Scenario:
And I press button "User Confirmation"
And I press Modal button "Ok"
Then Toast display should contains text "Confirm country"
Then Toast display should contain text "Confirm country"

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

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

Scenario: testing multi in panel
And I press button "Multi Step"
Expand All @@ -66,4 +66,4 @@ Feature: UserAction
Then I press Panel button "Next"
Then Panel is open with text "Gender = m / Age = 22"
Then I press Panel button "Multi Step"
Then Toast display should contains text "Thank you Mr. at age 22"
Then Toast display should contain text "Thank you Mr. at age 22"
12 changes: 6 additions & 6 deletions tests-behat/virtual-page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: VirtualPage
Scenario:
Given I am on "interactive/virtual.php"
Then I click link 'More info on Car'
Then text in container using '.__atk-behat-test-car' should contains 'Car'
Then text in container using '.__atk-behat-test-car' should contain 'Car'
Then I press button "Open Lorem Ipsum"
Then Modal is open with text 'This is yet another modal'

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

Scenario:
Given I am on "_unit-test/virtual-page.php"
Then I click link 'Open First'
Then text in container using '.__atk-behat-test-first' should contains 'First Level Page'
Then text in container using '.__atk-behat-test-first' should contain 'First Level Page'
Then I click link 'Open Second'
Then text in container using '.__atk-behat-test-second' should contains 'Second Level Page'
Then text in container using '.__atk-behat-test-second' should contain 'Second Level Page'
Then I click link 'Open Third'
Then text in container using '.__atk-behat-test-third' should contains 'Third Level Page'
Then text in container using '.__atk-behat-test-third' should contain 'Third Level Page'
Then I select value "Beverages" in lookup "category"
Then I press button "Save"
Then Toast display should contains text 'Beverages'
Then Toast display should contain text 'Beverages'

0 comments on commit 22246c8

Please sign in to comment.