2017-04-04 18:20:19 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Behat\Behat\Context\Context;
|
|
|
|
|
2019-11-20 19:09:52 +03:00
|
|
|
class ToastContext implements Context, ActorAwareInterface {
|
2017-04-04 18:20:19 +03:00
|
|
|
|
|
|
|
use ActorAware;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Locator
|
|
|
|
*/
|
2019-11-20 19:09:52 +03:00
|
|
|
public static function toastMessage($message) {
|
2019-06-12 15:32:15 +03:00
|
|
|
return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' toastify ') and normalize-space(text()) = '$message']")->
|
2019-11-20 19:09:52 +03:00
|
|
|
descendantOf(self::toastContainer())->
|
|
|
|
describedAs("$message toast");
|
2017-04-04 18:20:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Locator
|
|
|
|
*/
|
2019-11-20 19:09:52 +03:00
|
|
|
private static function toastContainer() {
|
2019-06-12 15:32:15 +03:00
|
|
|
return Locator::forThe()->id("content")->
|
2019-11-20 19:09:52 +03:00
|
|
|
describedAs("Toast container");
|
2017-04-04 18:20:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-11-20 19:09:52 +03:00
|
|
|
* @Then I see that the :message toast is shown
|
2017-04-04 18:20:19 +03:00
|
|
|
*/
|
2019-11-20 19:09:52 +03:00
|
|
|
public function iSeeThatTheToastIsShown($message) {
|
2017-04-04 18:20:19 +03:00
|
|
|
PHPUnit_Framework_Assert::assertTrue($this->actor->find(
|
2019-11-20 19:09:52 +03:00
|
|
|
self::toastMessage($message), 10)->isVisible());
|
2017-04-04 18:20:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|