├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .travis.yml ├── LICENSE.md ├── README.md ├── composer.json ├── composer.lock ├── src ├── Firebase.php ├── web │ └── Application.php └── yii2 │ ├── BaseYii.php │ └── Yii.php └── tests ├── codeception.yml ├── tests ├── FirebaseTest.php ├── _bootstrap.php ├── _data │ └── .gitkeep ├── _output │ └── .gitkeep ├── _support │ ├── AcceptanceTester.php │ ├── FunctionalTester.php │ ├── Helper │ │ ├── Acceptance.php │ │ ├── Functional.php │ │ └── Unit.php │ ├── UnitTester.php │ └── _generated │ │ ├── AcceptanceTesterActions.php │ │ ├── FunctionalTesterActions.php │ │ └── UnitTesterActions.php ├── acceptance.suite.yml ├── acceptance │ └── _bootstrap.php ├── config │ ├── config-local.php │ ├── config.php │ └── web.php ├── functional.suite.yml ├── functional │ └── _bootstrap.php ├── unit.suite.yml └── unit │ ├── FirebaseDatabaseTest.php │ └── _bootstrap.php └── web ├── assets └── .gitignore └── index-test.php /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | .idea -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - '7.0' 4 | 5 | # faster builds on new travis setup not using sudo 6 | sudo: false 7 | 8 | # cache composer cache 9 | cache: 10 | directories: 11 | - $HOME/.composer/cache 12 | 13 | install: 14 | - travis_retry composer self-update && composer --version 15 | - travis_retry composer global require "fxp/composer-asset-plugin:^1.3.1" 16 | - export PATH="$HOME/.composer/vendor/bin:$PATH" 17 | - travis_retry composer install --dev --prefer-dist --no-interaction 18 | # codeception 19 | - travis_retry composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*" 20 | # setup application: 21 | - | 22 | cd tests 23 | codecept build 24 | cd .. 25 | 26 | script: 27 | - | 28 | cd tests 29 | codecept run -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Jérôme Gamez, https://github.com/jeromegamez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # yii2-firebase 2 | 3 | [![Latest Stable Version](https://poser.pugx.org/grptx/yii2-firebase/v/stable)](https://packagist.org/packages/grptx/yii2-firebase) 4 | [![Total Downloads](https://poser.pugx.org/grptx/yii2-firebase/downloads)](https://packagist.org/packages/grptx/yii2-firebase) 5 | [![Latest Unstable Version](https://poser.pugx.org/grptx/yii2-firebase/v/unstable)](https://packagist.org/packages/grptx/yii2-firebase) 6 | [![License](https://poser.pugx.org/grptx/yii2-firebase/license)](https://packagist.org/packages/grptx/yii2-firebase) 7 | 8 | This Yii2 component wraps [kreait/firebase-php](https://github.com/kreait/firebase-php/) and allow to easy connect to the Firebase realtime database 9 | 10 | ## Installation 11 | 12 | Preferred way to install is through [Composer](https://getcomposer.org): 13 | ```shell 14 | php composer.phar require grptx/yii2-firebase:~0.3.1 15 | ``` 16 | Or, you may add 17 | 18 | ```php 19 | "grptx/yii2-firebase": "~0.3.1" 20 | ``` 21 | 22 | to the require section of your `composer.json` file and execute `php composer.phar update`. 23 | 24 | ## Configuration 25 | 26 | ```php 27 | ... 28 | 'components' => [ 29 | 'firebase' => [ 30 | 'class'=>'grptx\Firebase\Firebase', 31 | 'credential_file'=>'service_account.json', // (see https://firebase.google.com/docs/admin/setup#add_firebase_to_your_app) 32 | 'database_uri'=>'https://my-project.firebaseio.com', // (optional) 33 | ] 34 | ... 35 | ] 36 | ``` 37 | 38 | ### Optional 39 | to use the autocomplete function of IDE (i.e. Phpstorm) you can optionally replace in the web/index.php the inclusion of Yii.php file and the Application instance: 40 | 41 | replace: 42 | ```php 43 | require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); 44 | //and 45 | (new yii\web\Application($config))->run(); 46 | ``` 47 | with: 48 | ```php 49 | require (__DIR__.'/../../vendor/grptx/yii2-firebase/src/yii2/Yii.php'); 50 | //and 51 | (new \grptx\Firebase\web\Application($config))->run(); 52 | 53 | ``` 54 | now when you need you can use grptx\Firebase\yii2\Yii instead of Yii to use autocomplete of your IDE 55 | 56 | ## Usage 57 | 58 | Retrive a _database_ ,_reference_ and a _value_ 59 | ```php 60 | $database = Yii::$app->firebase->getDatabase(); 61 | $reference = $database->getReference('path/to/child/location'); 62 | $value = $reference->getValue(); 63 | ``` 64 | 65 | or just the _reference_ and a _value_ 66 | 67 | ```php 68 | $reference = Yii::$app->firebase->getReference('path/to/child/location'); 69 | $value = $reference->getValue(); 70 | ``` 71 | 72 | for other method see [firebase-php.readthedocs.io.](https://firebase-php.readthedocs.io/en/latest/realtime-database.html) -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grptx/yii2-firebase", 3 | "type": "yii2-extension", 4 | "authors": [ 5 | { 6 | "name": "grptx", 7 | "email": "r.rossetti@melogra.no" 8 | } 9 | ], 10 | "license": "MIT", 11 | "keywords": [ 12 | "yii2", 13 | "yii2-components", 14 | "firebase", 15 | "php7" 16 | ], 17 | "description": "Yii2 Component to connect to Firebase Database", 18 | "require": { 19 | "yiisoft/yii2": "^2", 20 | "kreait/firebase-php": "^4.0" 21 | }, 22 | "require-dev": { 23 | "codeception/codeception": "*", 24 | "codeception/specify": "*", 25 | "codeception/verify": "*", 26 | "yiisoft/yii2-faker":"*" 27 | }, 28 | "minimum-stability": "dev", 29 | "autoload": { 30 | "psr-4": { 31 | "grptx\\Firebase\\": "src", 32 | "grptx\\tests\\":"tests/tests" 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Firebase.php: -------------------------------------------------------------------------------- 1 | _serviceAccount) { 41 | try { 42 | if (!$this->credential_file) { 43 | $this->_serviceAccount = ServiceAccount::discover(); 44 | } else { 45 | $this->_serviceAccount = ServiceAccount::fromJsonFile($this->credential_file); 46 | } 47 | } catch (ServiceAccountDiscoveryFailed $e) { 48 | $this->_serviceAccount = null; 49 | } 50 | 51 | } 52 | return $this->_serviceAccount; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getDataBaseUri(): string 59 | { 60 | return $this->database_uri; 61 | } 62 | 63 | /** 64 | * @return \Kreait\Firebase 65 | */ 66 | public function getFirebase(): \Kreait\Firebase 67 | { 68 | if (!$this->_firebase) { 69 | if ($this->getServiceAccount()) { 70 | $factory = (new Factory)->withServiceAccount($this->getServiceAccount()); 71 | if ($this->getDataBaseUri()) { 72 | $this->_firebase = $factory->withDatabaseUri($this->getDataBaseUri())->create(); 73 | } else { 74 | $this->_firebase = (new Factory)->withServiceAccount($this->getServiceAccount())->create(); 75 | } 76 | } else if ($this->getDataBaseUri()) { 77 | $this->_firebase = (new Factory)->withDatabaseUri($this->getDataBaseUri())->create(); 78 | } else { 79 | throw new ServiceAccountDiscoveryFailed("cannot retrieve Firebase istance"); 80 | } 81 | } 82 | return $this->_firebase; 83 | } 84 | 85 | /** 86 | * @return Database 87 | */ 88 | public function getDatabase(): Database 89 | { 90 | if (!$this->_database) { 91 | if ($this->getFirebase()) { 92 | $this->_database = $this->getFirebase()->getDatabase(); 93 | } 94 | } 95 | return $this->_database; 96 | } 97 | 98 | /** 99 | * @param string $path 100 | * @return Reference 101 | */ 102 | public function getReference(string $path = ''): Reference 103 | { 104 | return $this->getDatabase()->getReference($path); 105 | } 106 | 107 | /** 108 | * @param $uri 109 | * @return Reference 110 | */ 111 | public function getReferenceFromUrl($uri): Reference 112 | { 113 | return $this->getDatabase()->getReferenceFromUrl($uri); 114 | } 115 | 116 | } -------------------------------------------------------------------------------- /src/web/Application.php: -------------------------------------------------------------------------------- 1 | 21 | * @author Roberto Rossetti 22 | * @since 2.0 23 | */ 24 | class Yii extends BaseYii 25 | { 26 | } 27 | 28 | spl_autoload_register(['Yii', 'autoload'], true, true); 29 | Yii::$classMap = require(__DIR__ . '/../../../../yiisoft/yii2/classes.php'); 30 | Yii::$container = new Container(); -------------------------------------------------------------------------------- /tests/codeception.yml: -------------------------------------------------------------------------------- 1 | paths: 2 | tests: tests 3 | output: tests/_output 4 | data: tests/_data 5 | support: tests/_support 6 | envs: tests/_envs 7 | log: tests/_log 8 | helpers: tests/_support 9 | 10 | actor_suffix: Tester 11 | 12 | 13 | settings: 14 | bootstrap: _bootstrap.php 15 | suite_class: \PHPUnit_Framework_TestSuite 16 | memory_limit: 1024M 17 | log: true 18 | colors: true 19 | config: 20 | # the entry script URL (with host info) for functional and acceptance tests 21 | # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL 22 | test_entry_url: http://localhost:8081/index-test.php 23 | 24 | modules: 25 | config: 26 | Yii2: 27 | configFile: 'tests/config/config-local.php' 28 | -------------------------------------------------------------------------------- /tests/tests/FirebaseTest.php: -------------------------------------------------------------------------------- 1 | firebaseTestCase = new FirebaseYiiTestCase(); 43 | $this->serviceAccount = $this->firebaseTestCase->createServiceAccountMock(); 44 | $this->databaseUri = new Uri( 'https://database-uri.tld' ); 45 | $this->tokenHandler = new Handler( 'projectid', 'clientEmail', 'privateKey' ); 46 | 47 | $this->firebase = new Firebase( $this->serviceAccount, $this->databaseUri, $this->tokenHandler ); 48 | } 49 | 50 | /** 51 | * Firebase constructor. 52 | */ 53 | public function __construct() { 54 | parent::__construct([]); 55 | $this->setUp(); 56 | } 57 | 58 | public function getServiceAccount(): ServiceAccount 59 | { 60 | return $this->serviceAccount; 61 | } 62 | } 63 | 64 | class FirebaseYiiTestCase extends TestCase { 65 | protected $fixturesDir = __DIR__.'/_fixtures'; 66 | 67 | /** 68 | * @return ServiceAccount|\PHPUnit_Framework_MockObject_MockObject 69 | */ 70 | public function createServiceAccountMock() 71 | { 72 | $mock = $this->createMock(ServiceAccount::class); 73 | 74 | $mock->expects($this->any()) 75 | ->method('getProjectId') 76 | ->willReturn('project'); 77 | 78 | $mock->expects($this->any()) 79 | ->method('getClientId') 80 | ->willReturn('client'); 81 | 82 | $mock->expects($this->any()) 83 | ->method('getClientEmail') 84 | ->willReturn('client@email.tld'); 85 | 86 | $mock->expects($this->any()) 87 | ->method('getPrivateKey') 88 | ->willReturn('some private key'); 89 | 90 | return $mock; 91 | } 92 | } -------------------------------------------------------------------------------- /tests/tests/_bootstrap.php: -------------------------------------------------------------------------------- 1 | getScenario()->runStep(new \Codeception\Step\Action('setHeader', func_get_args())); 29 | } 30 | 31 | 32 | /** 33 | * [!] Method is generated. Documentation taken from corresponding module. 34 | * 35 | * Authenticates user for HTTP_AUTH 36 | * 37 | * @param $username 38 | * @param $password 39 | * @see \Codeception\Module\PhpBrowser::amHttpAuthenticated() 40 | */ 41 | public function amHttpAuthenticated($username, $password) { 42 | return $this->getScenario()->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args())); 43 | } 44 | 45 | 46 | /** 47 | * [!] Method is generated. Documentation taken from corresponding module. 48 | * 49 | * Open web page at the given absolute URL and sets its hostname as the base host. 50 | * 51 | * ``` php 52 | * amOnUrl('http://codeception.com'); 54 | * $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart 55 | * ?> 56 | * ``` 57 | * @see \Codeception\Module\PhpBrowser::amOnUrl() 58 | */ 59 | public function amOnUrl($url) { 60 | return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args())); 61 | } 62 | 63 | 64 | /** 65 | * [!] Method is generated. Documentation taken from corresponding module. 66 | * 67 | * Changes the subdomain for the 'url' configuration parameter. 68 | * Does not open a page; use `amOnPage` for that. 69 | * 70 | * ``` php 71 | * amOnSubdomain('user'); 77 | * $I->amOnPage('/'); 78 | * // moves to http://user.mysite.com/ 79 | * ?> 80 | * ``` 81 | * 82 | * @param $subdomain 83 | * 84 | * @return mixed 85 | * @see \Codeception\Module\PhpBrowser::amOnSubdomain() 86 | */ 87 | public function amOnSubdomain($subdomain) { 88 | return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args())); 89 | } 90 | 91 | 92 | /** 93 | * [!] Method is generated. Documentation taken from corresponding module. 94 | * 95 | * Low-level API method. 96 | * If Codeception commands are not enough, use [Guzzle HTTP Client](http://guzzlephp.org/) methods directly 97 | * 98 | * Example: 99 | * 100 | * ``` php 101 | * executeInGuzzle(function (\GuzzleHttp\Client $client) { 103 | * $client->get('/get', ['query' => ['foo' => 'bar']]); 104 | * }); 105 | * ?> 106 | * ``` 107 | * 108 | * It is not recommended to use this command on a regular basis. 109 | * If Codeception lacks important Guzzle Client methods, implement them and submit patches. 110 | * 111 | * @param callable $function 112 | * @see \Codeception\Module\PhpBrowser::executeInGuzzle() 113 | */ 114 | public function executeInGuzzle($function) { 115 | return $this->getScenario()->runStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args())); 116 | } 117 | 118 | 119 | /** 120 | * [!] Method is generated. Documentation taken from corresponding module. 121 | * 122 | * Sets the HTTP header to the passed value - which is used on 123 | * subsequent HTTP requests through PhpBrowser. 124 | * 125 | * Example: 126 | * ```php 127 | * setHeader('X-Requested-With', 'Codeception'); 129 | * $I->amOnPage('test-headers.php'); 130 | * ?> 131 | * ``` 132 | * 133 | * @param string $name the name of the request header 134 | * @param string $value the value to set it to for subsequent 135 | * requests 136 | * @see \Codeception\Lib\InnerBrowser::haveHttpHeader() 137 | */ 138 | public function haveHttpHeader($name, $value) { 139 | return $this->getScenario()->runStep(new \Codeception\Step\Action('haveHttpHeader', func_get_args())); 140 | } 141 | 142 | 143 | /** 144 | * [!] Method is generated. Documentation taken from corresponding module. 145 | * 146 | * Deletes the header with the passed name. Subsequent requests 147 | * will not have the deleted header in its request. 148 | * 149 | * Example: 150 | * ```php 151 | * haveHttpHeader('X-Requested-With', 'Codeception'); 153 | * $I->amOnPage('test-headers.php'); 154 | * // ... 155 | * $I->deleteHeader('X-Requested-With'); 156 | * $I->amOnPage('some-other-page.php'); 157 | * ?> 158 | * ``` 159 | * 160 | * @param string $name the name of the header to delete. 161 | * @see \Codeception\Lib\InnerBrowser::deleteHeader() 162 | */ 163 | public function deleteHeader($name) { 164 | return $this->getScenario()->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args())); 165 | } 166 | 167 | 168 | /** 169 | * [!] Method is generated. Documentation taken from corresponding module. 170 | * 171 | * Opens the page for the given relative URI. 172 | * 173 | * ``` php 174 | * amOnPage('/'); 177 | * // opens /register page 178 | * $I->amOnPage('/register'); 179 | * ``` 180 | * 181 | * @param $page 182 | * @see \Codeception\Lib\InnerBrowser::amOnPage() 183 | */ 184 | public function amOnPage($page) { 185 | return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); 186 | } 187 | 188 | 189 | /** 190 | * [!] Method is generated. Documentation taken from corresponding module. 191 | * 192 | * Perform a click on a link or a button, given by a locator. 193 | * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. 194 | * For buttons, the "value" attribute, "name" attribute, and inner text are searched. 195 | * For links, the link text is searched. 196 | * For images, the "alt" attribute and inner text of any parent links are searched. 197 | * 198 | * The second parameter is a context (CSS or XPath locator) to narrow the search. 199 | * 200 | * Note that if the locator matches a button of type `submit`, the form will be submitted. 201 | * 202 | * ``` php 203 | * click('Logout'); 206 | * // button of form 207 | * $I->click('Submit'); 208 | * // CSS button 209 | * $I->click('#form input[type=submit]'); 210 | * // XPath 211 | * $I->click('//form/*[@type=submit]'); 212 | * // link in context 213 | * $I->click('Logout', '#nav'); 214 | * // using strict locator 215 | * $I->click(['link' => 'Login']); 216 | * ?> 217 | * ``` 218 | * 219 | * @param $link 220 | * @param $context 221 | * @see \Codeception\Lib\InnerBrowser::click() 222 | */ 223 | public function click($link, $context = null) { 224 | return $this->getScenario()->runStep(new \Codeception\Step\Action('click', func_get_args())); 225 | } 226 | 227 | 228 | /** 229 | * [!] Method is generated. Documentation taken from corresponding module. 230 | * 231 | * Checks that the current page contains the given string (case insensitive). 232 | * 233 | * You can specify a specific HTML element (via CSS or XPath) as the second 234 | * parameter to only search within that element. 235 | * 236 | * ``` php 237 | * see('Logout'); // I can suppose user is logged in 239 | * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page 240 | * $I->see('Sign Up', '//body/h1'); // with XPath 241 | * $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator 242 | * ``` 243 | * 244 | * Note that the search is done after stripping all HTML tags from the body, 245 | * so `$I->see('strong')` will return true for strings like: 246 | * 247 | * - `

I am Stronger than thou

` 248 | * - `` 249 | * 250 | * But will *not* be true for strings like: 251 | * 252 | * - `Home` 253 | * - `
Home` 254 | * - `` 255 | * 256 | * For checking the raw source code, use `seeInSource()`. 257 | * 258 | * @param $text 259 | * @param null $selector 260 | * Conditional Assertion: Test won't be stopped on fail 261 | * @see \Codeception\Lib\InnerBrowser::see() 262 | */ 263 | public function canSee($text, $selector = null) { 264 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); 265 | } 266 | /** 267 | * [!] Method is generated. Documentation taken from corresponding module. 268 | * 269 | * Checks that the current page contains the given string (case insensitive). 270 | * 271 | * You can specify a specific HTML element (via CSS or XPath) as the second 272 | * parameter to only search within that element. 273 | * 274 | * ``` php 275 | * see('Logout'); // I can suppose user is logged in 277 | * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page 278 | * $I->see('Sign Up', '//body/h1'); // with XPath 279 | * $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator 280 | * ``` 281 | * 282 | * Note that the search is done after stripping all HTML tags from the body, 283 | * so `$I->see('strong')` will return true for strings like: 284 | * 285 | * - `

I am Stronger than thou

` 286 | * - `` 287 | * 288 | * But will *not* be true for strings like: 289 | * 290 | * - `Home` 291 | * - `
Home` 292 | * - `` 293 | * 294 | * For checking the raw source code, use `seeInSource()`. 295 | * 296 | * @param $text 297 | * @param null $selector 298 | * @see \Codeception\Lib\InnerBrowser::see() 299 | */ 300 | public function see($text, $selector = null) { 301 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args())); 302 | } 303 | 304 | 305 | /** 306 | * [!] Method is generated. Documentation taken from corresponding module. 307 | * 308 | * Checks that the current page doesn't contain the text specified (case insensitive). 309 | * Give a locator as the second parameter to match a specific region. 310 | * 311 | * ```php 312 | * dontSee('Login'); // I can suppose user is already logged in 314 | * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page 315 | * $I->dontSee('Sign Up','//body/h1'); // with XPath 316 | * $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator 317 | * ``` 318 | * 319 | * Note that the search is done after stripping all HTML tags from the body, 320 | * so `$I->dontSee('strong')` will fail on strings like: 321 | * 322 | * - `

I am Stronger than thou

` 323 | * - `` 324 | * 325 | * But will ignore strings like: 326 | * 327 | * - `Home` 328 | * - `
Home` 329 | * - `` 330 | * 331 | * For checking the raw source code, use `seeInSource()`. 332 | * 333 | * @param $text 334 | * @param null $selector 335 | * Conditional Assertion: Test won't be stopped on fail 336 | * @see \Codeception\Lib\InnerBrowser::dontSee() 337 | */ 338 | public function cantSee($text, $selector = null) { 339 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); 340 | } 341 | /** 342 | * [!] Method is generated. Documentation taken from corresponding module. 343 | * 344 | * Checks that the current page doesn't contain the text specified (case insensitive). 345 | * Give a locator as the second parameter to match a specific region. 346 | * 347 | * ```php 348 | * dontSee('Login'); // I can suppose user is already logged in 350 | * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page 351 | * $I->dontSee('Sign Up','//body/h1'); // with XPath 352 | * $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator 353 | * ``` 354 | * 355 | * Note that the search is done after stripping all HTML tags from the body, 356 | * so `$I->dontSee('strong')` will fail on strings like: 357 | * 358 | * - `

I am Stronger than thou

` 359 | * - `` 360 | * 361 | * But will ignore strings like: 362 | * 363 | * - `Home` 364 | * - `
Home` 365 | * - `` 366 | * 367 | * For checking the raw source code, use `seeInSource()`. 368 | * 369 | * @param $text 370 | * @param null $selector 371 | * @see \Codeception\Lib\InnerBrowser::dontSee() 372 | */ 373 | public function dontSee($text, $selector = null) { 374 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); 375 | } 376 | 377 | 378 | /** 379 | * [!] Method is generated. Documentation taken from corresponding module. 380 | * 381 | * Checks that the current page contains the given string in its 382 | * raw source code. 383 | * 384 | * ``` php 385 | * seeInSource('

Green eggs & ham

'); 387 | * ``` 388 | * 389 | * @param $raw 390 | * Conditional Assertion: Test won't be stopped on fail 391 | * @see \Codeception\Lib\InnerBrowser::seeInSource() 392 | */ 393 | public function canSeeInSource($raw) { 394 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSource', func_get_args())); 395 | } 396 | /** 397 | * [!] Method is generated. Documentation taken from corresponding module. 398 | * 399 | * Checks that the current page contains the given string in its 400 | * raw source code. 401 | * 402 | * ``` php 403 | * seeInSource('

Green eggs & ham

'); 405 | * ``` 406 | * 407 | * @param $raw 408 | * @see \Codeception\Lib\InnerBrowser::seeInSource() 409 | */ 410 | public function seeInSource($raw) { 411 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSource', func_get_args())); 412 | } 413 | 414 | 415 | /** 416 | * [!] Method is generated. Documentation taken from corresponding module. 417 | * 418 | * Checks that the current page contains the given string in its 419 | * raw source code. 420 | * 421 | * ```php 422 | * dontSeeInSource('

Green eggs & ham

'); 424 | * ``` 425 | * 426 | * @param $raw 427 | * Conditional Assertion: Test won't be stopped on fail 428 | * @see \Codeception\Lib\InnerBrowser::dontSeeInSource() 429 | */ 430 | public function cantSeeInSource($raw) { 431 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInSource', func_get_args())); 432 | } 433 | /** 434 | * [!] Method is generated. Documentation taken from corresponding module. 435 | * 436 | * Checks that the current page contains the given string in its 437 | * raw source code. 438 | * 439 | * ```php 440 | * dontSeeInSource('

Green eggs & ham

'); 442 | * ``` 443 | * 444 | * @param $raw 445 | * @see \Codeception\Lib\InnerBrowser::dontSeeInSource() 446 | */ 447 | public function dontSeeInSource($raw) { 448 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInSource', func_get_args())); 449 | } 450 | 451 | 452 | /** 453 | * [!] Method is generated. Documentation taken from corresponding module. 454 | * 455 | * Checks that there's a link with the specified text. 456 | * Give a full URL as the second parameter to match links with that exact URL. 457 | * 458 | * ``` php 459 | * seeLink('Logout'); // matches Logout 461 | * $I->seeLink('Logout','/logout'); // matches Logout 462 | * ?> 463 | * ``` 464 | * 465 | * @param $text 466 | * @param null $url 467 | * Conditional Assertion: Test won't be stopped on fail 468 | * @see \Codeception\Lib\InnerBrowser::seeLink() 469 | */ 470 | public function canSeeLink($text, $url = null) { 471 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); 472 | } 473 | /** 474 | * [!] Method is generated. Documentation taken from corresponding module. 475 | * 476 | * Checks that there's a link with the specified text. 477 | * Give a full URL as the second parameter to match links with that exact URL. 478 | * 479 | * ``` php 480 | * seeLink('Logout'); // matches Logout 482 | * $I->seeLink('Logout','/logout'); // matches Logout 483 | * ?> 484 | * ``` 485 | * 486 | * @param $text 487 | * @param null $url 488 | * @see \Codeception\Lib\InnerBrowser::seeLink() 489 | */ 490 | public function seeLink($text, $url = null) { 491 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); 492 | } 493 | 494 | 495 | /** 496 | * [!] Method is generated. Documentation taken from corresponding module. 497 | * 498 | * Checks that the page doesn't contain a link with the given string. 499 | * If the second parameter is given, only links with a matching "href" attribute will be checked. 500 | * 501 | * ``` php 502 | * dontSeeLink('Logout'); // I suppose user is not logged in 504 | * $I->dontSeeLink('Checkout now', '/store/cart.php'); 505 | * ?> 506 | * ``` 507 | * 508 | * @param $text 509 | * @param null $url 510 | * Conditional Assertion: Test won't be stopped on fail 511 | * @see \Codeception\Lib\InnerBrowser::dontSeeLink() 512 | */ 513 | public function cantSeeLink($text, $url = null) { 514 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); 515 | } 516 | /** 517 | * [!] Method is generated. Documentation taken from corresponding module. 518 | * 519 | * Checks that the page doesn't contain a link with the given string. 520 | * If the second parameter is given, only links with a matching "href" attribute will be checked. 521 | * 522 | * ``` php 523 | * dontSeeLink('Logout'); // I suppose user is not logged in 525 | * $I->dontSeeLink('Checkout now', '/store/cart.php'); 526 | * ?> 527 | * ``` 528 | * 529 | * @param $text 530 | * @param null $url 531 | * @see \Codeception\Lib\InnerBrowser::dontSeeLink() 532 | */ 533 | public function dontSeeLink($text, $url = null) { 534 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); 535 | } 536 | 537 | 538 | /** 539 | * [!] Method is generated. Documentation taken from corresponding module. 540 | * 541 | * Checks that current URI contains the given string. 542 | * 543 | * ``` php 544 | * seeInCurrentUrl('home'); 547 | * // to match: /users/1 548 | * $I->seeInCurrentUrl('/users/'); 549 | * ?> 550 | * ``` 551 | * 552 | * @param $uri 553 | * Conditional Assertion: Test won't be stopped on fail 554 | * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() 555 | */ 556 | public function canSeeInCurrentUrl($uri) { 557 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); 558 | } 559 | /** 560 | * [!] Method is generated. Documentation taken from corresponding module. 561 | * 562 | * Checks that current URI contains the given string. 563 | * 564 | * ``` php 565 | * seeInCurrentUrl('home'); 568 | * // to match: /users/1 569 | * $I->seeInCurrentUrl('/users/'); 570 | * ?> 571 | * ``` 572 | * 573 | * @param $uri 574 | * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() 575 | */ 576 | public function seeInCurrentUrl($uri) { 577 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); 578 | } 579 | 580 | 581 | /** 582 | * [!] Method is generated. Documentation taken from corresponding module. 583 | * 584 | * Checks that the current URI doesn't contain the given string. 585 | * 586 | * ``` php 587 | * dontSeeInCurrentUrl('/users/'); 589 | * ?> 590 | * ``` 591 | * 592 | * @param $uri 593 | * Conditional Assertion: Test won't be stopped on fail 594 | * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() 595 | */ 596 | public function cantSeeInCurrentUrl($uri) { 597 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); 598 | } 599 | /** 600 | * [!] Method is generated. Documentation taken from corresponding module. 601 | * 602 | * Checks that the current URI doesn't contain the given string. 603 | * 604 | * ``` php 605 | * dontSeeInCurrentUrl('/users/'); 607 | * ?> 608 | * ``` 609 | * 610 | * @param $uri 611 | * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() 612 | */ 613 | public function dontSeeInCurrentUrl($uri) { 614 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); 615 | } 616 | 617 | 618 | /** 619 | * [!] Method is generated. Documentation taken from corresponding module. 620 | * 621 | * Checks that the current URL is equal to the given string. 622 | * Unlike `seeInCurrentUrl`, this only matches the full URL. 623 | * 624 | * ``` php 625 | * seeCurrentUrlEquals('/'); 628 | * ?> 629 | * ``` 630 | * 631 | * @param $uri 632 | * Conditional Assertion: Test won't be stopped on fail 633 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() 634 | */ 635 | public function canSeeCurrentUrlEquals($uri) { 636 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); 637 | } 638 | /** 639 | * [!] Method is generated. Documentation taken from corresponding module. 640 | * 641 | * Checks that the current URL is equal to the given string. 642 | * Unlike `seeInCurrentUrl`, this only matches the full URL. 643 | * 644 | * ``` php 645 | * seeCurrentUrlEquals('/'); 648 | * ?> 649 | * ``` 650 | * 651 | * @param $uri 652 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() 653 | */ 654 | public function seeCurrentUrlEquals($uri) { 655 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); 656 | } 657 | 658 | 659 | /** 660 | * [!] Method is generated. Documentation taken from corresponding module. 661 | * 662 | * Checks that the current URL doesn't equal the given string. 663 | * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. 664 | * 665 | * ``` php 666 | * dontSeeCurrentUrlEquals('/'); 669 | * ?> 670 | * ``` 671 | * 672 | * @param $uri 673 | * Conditional Assertion: Test won't be stopped on fail 674 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() 675 | */ 676 | public function cantSeeCurrentUrlEquals($uri) { 677 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); 678 | } 679 | /** 680 | * [!] Method is generated. Documentation taken from corresponding module. 681 | * 682 | * Checks that the current URL doesn't equal the given string. 683 | * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. 684 | * 685 | * ``` php 686 | * dontSeeCurrentUrlEquals('/'); 689 | * ?> 690 | * ``` 691 | * 692 | * @param $uri 693 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() 694 | */ 695 | public function dontSeeCurrentUrlEquals($uri) { 696 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); 697 | } 698 | 699 | 700 | /** 701 | * [!] Method is generated. Documentation taken from corresponding module. 702 | * 703 | * Checks that the current URL matches the given regular expression. 704 | * 705 | * ``` php 706 | * seeCurrentUrlMatches('~$/users/(\d+)~'); 709 | * ?> 710 | * ``` 711 | * 712 | * @param $uri 713 | * Conditional Assertion: Test won't be stopped on fail 714 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() 715 | */ 716 | public function canSeeCurrentUrlMatches($uri) { 717 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); 718 | } 719 | /** 720 | * [!] Method is generated. Documentation taken from corresponding module. 721 | * 722 | * Checks that the current URL matches the given regular expression. 723 | * 724 | * ``` php 725 | * seeCurrentUrlMatches('~$/users/(\d+)~'); 728 | * ?> 729 | * ``` 730 | * 731 | * @param $uri 732 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() 733 | */ 734 | public function seeCurrentUrlMatches($uri) { 735 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); 736 | } 737 | 738 | 739 | /** 740 | * [!] Method is generated. Documentation taken from corresponding module. 741 | * 742 | * Checks that current url doesn't match the given regular expression. 743 | * 744 | * ``` php 745 | * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); 748 | * ?> 749 | * ``` 750 | * 751 | * @param $uri 752 | * Conditional Assertion: Test won't be stopped on fail 753 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() 754 | */ 755 | public function cantSeeCurrentUrlMatches($uri) { 756 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); 757 | } 758 | /** 759 | * [!] Method is generated. Documentation taken from corresponding module. 760 | * 761 | * Checks that current url doesn't match the given regular expression. 762 | * 763 | * ``` php 764 | * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); 767 | * ?> 768 | * ``` 769 | * 770 | * @param $uri 771 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() 772 | */ 773 | public function dontSeeCurrentUrlMatches($uri) { 774 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); 775 | } 776 | 777 | 778 | /** 779 | * [!] Method is generated. Documentation taken from corresponding module. 780 | * 781 | * Executes the given regular expression against the current URI and returns the first match. 782 | * If no parameters are provided, the full URI is returned. 783 | * 784 | * ``` php 785 | * grabFromCurrentUrl('~$/user/(\d+)/~'); 787 | * $uri = $I->grabFromCurrentUrl(); 788 | * ?> 789 | * ``` 790 | * 791 | * @param null $uri 792 | * 793 | * @return mixed 794 | * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() 795 | */ 796 | public function grabFromCurrentUrl($uri = null) { 797 | return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); 798 | } 799 | 800 | 801 | /** 802 | * [!] Method is generated. Documentation taken from corresponding module. 803 | * 804 | * Checks that the specified checkbox is checked. 805 | * 806 | * ``` php 807 | * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms 809 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. 810 | * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); 811 | * ?> 812 | * ``` 813 | * 814 | * @param $checkbox 815 | * Conditional Assertion: Test won't be stopped on fail 816 | * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() 817 | */ 818 | public function canSeeCheckboxIsChecked($checkbox) { 819 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); 820 | } 821 | /** 822 | * [!] Method is generated. Documentation taken from corresponding module. 823 | * 824 | * Checks that the specified checkbox is checked. 825 | * 826 | * ``` php 827 | * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms 829 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. 830 | * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); 831 | * ?> 832 | * ``` 833 | * 834 | * @param $checkbox 835 | * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() 836 | */ 837 | public function seeCheckboxIsChecked($checkbox) { 838 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); 839 | } 840 | 841 | 842 | /** 843 | * [!] Method is generated. Documentation taken from corresponding module. 844 | * 845 | * Check that the specified checkbox is unchecked. 846 | * 847 | * ``` php 848 | * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms 850 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. 851 | * ?> 852 | * ``` 853 | * 854 | * @param $checkbox 855 | * Conditional Assertion: Test won't be stopped on fail 856 | * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() 857 | */ 858 | public function cantSeeCheckboxIsChecked($checkbox) { 859 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); 860 | } 861 | /** 862 | * [!] Method is generated. Documentation taken from corresponding module. 863 | * 864 | * Check that the specified checkbox is unchecked. 865 | * 866 | * ``` php 867 | * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms 869 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. 870 | * ?> 871 | * ``` 872 | * 873 | * @param $checkbox 874 | * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() 875 | */ 876 | public function dontSeeCheckboxIsChecked($checkbox) { 877 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); 878 | } 879 | 880 | 881 | /** 882 | * [!] Method is generated. Documentation taken from corresponding module. 883 | * 884 | * Checks that the given input field or textarea contains the given value. 885 | * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. 886 | * 887 | * ``` php 888 | * seeInField('Body','Type your comment here'); 890 | * $I->seeInField('form textarea[name=body]','Type your comment here'); 891 | * $I->seeInField('form input[type=hidden]','hidden_value'); 892 | * $I->seeInField('#searchform input','Search'); 893 | * $I->seeInField('//form/*[@name=search]','Search'); 894 | * $I->seeInField(['name' => 'search'], 'Search'); 895 | * ?> 896 | * ``` 897 | * 898 | * @param $field 899 | * @param $value 900 | * Conditional Assertion: Test won't be stopped on fail 901 | * @see \Codeception\Lib\InnerBrowser::seeInField() 902 | */ 903 | public function canSeeInField($field, $value) { 904 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); 905 | } 906 | /** 907 | * [!] Method is generated. Documentation taken from corresponding module. 908 | * 909 | * Checks that the given input field or textarea contains the given value. 910 | * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. 911 | * 912 | * ``` php 913 | * seeInField('Body','Type your comment here'); 915 | * $I->seeInField('form textarea[name=body]','Type your comment here'); 916 | * $I->seeInField('form input[type=hidden]','hidden_value'); 917 | * $I->seeInField('#searchform input','Search'); 918 | * $I->seeInField('//form/*[@name=search]','Search'); 919 | * $I->seeInField(['name' => 'search'], 'Search'); 920 | * ?> 921 | * ``` 922 | * 923 | * @param $field 924 | * @param $value 925 | * @see \Codeception\Lib\InnerBrowser::seeInField() 926 | */ 927 | public function seeInField($field, $value) { 928 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); 929 | } 930 | 931 | 932 | /** 933 | * [!] Method is generated. Documentation taken from corresponding module. 934 | * 935 | * Checks that an input field or textarea doesn't contain the given value. 936 | * For fuzzy locators, the field is matched by label text, CSS and XPath. 937 | * 938 | * ``` php 939 | * dontSeeInField('Body','Type your comment here'); 941 | * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); 942 | * $I->dontSeeInField('form input[type=hidden]','hidden_value'); 943 | * $I->dontSeeInField('#searchform input','Search'); 944 | * $I->dontSeeInField('//form/*[@name=search]','Search'); 945 | * $I->dontSeeInField(['name' => 'search'], 'Search'); 946 | * ?> 947 | * ``` 948 | * 949 | * @param $field 950 | * @param $value 951 | * Conditional Assertion: Test won't be stopped on fail 952 | * @see \Codeception\Lib\InnerBrowser::dontSeeInField() 953 | */ 954 | public function cantSeeInField($field, $value) { 955 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); 956 | } 957 | /** 958 | * [!] Method is generated. Documentation taken from corresponding module. 959 | * 960 | * Checks that an input field or textarea doesn't contain the given value. 961 | * For fuzzy locators, the field is matched by label text, CSS and XPath. 962 | * 963 | * ``` php 964 | * dontSeeInField('Body','Type your comment here'); 966 | * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); 967 | * $I->dontSeeInField('form input[type=hidden]','hidden_value'); 968 | * $I->dontSeeInField('#searchform input','Search'); 969 | * $I->dontSeeInField('//form/*[@name=search]','Search'); 970 | * $I->dontSeeInField(['name' => 'search'], 'Search'); 971 | * ?> 972 | * ``` 973 | * 974 | * @param $field 975 | * @param $value 976 | * @see \Codeception\Lib\InnerBrowser::dontSeeInField() 977 | */ 978 | public function dontSeeInField($field, $value) { 979 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); 980 | } 981 | 982 | 983 | /** 984 | * [!] Method is generated. Documentation taken from corresponding module. 985 | * 986 | * Checks if the array of form parameters (name => value) are set on the form matched with the 987 | * passed selector. 988 | * 989 | * ``` php 990 | * seeInFormFields('form[name=myform]', [ 992 | * 'input1' => 'value', 993 | * 'input2' => 'other value', 994 | * ]); 995 | * ?> 996 | * ``` 997 | * 998 | * For multi-select elements, or to check values of multiple elements with the same name, an 999 | * array may be passed: 1000 | * 1001 | * ``` php 1002 | * seeInFormFields('.form-class', [ 1004 | * 'multiselect' => [ 1005 | * 'value1', 1006 | * 'value2', 1007 | * ], 1008 | * 'checkbox[]' => [ 1009 | * 'a checked value', 1010 | * 'another checked value', 1011 | * ], 1012 | * ]); 1013 | * ?> 1014 | * ``` 1015 | * 1016 | * Additionally, checkbox values can be checked with a boolean. 1017 | * 1018 | * ``` php 1019 | * seeInFormFields('#form-id', [ 1021 | * 'checkbox1' => true, // passes if checked 1022 | * 'checkbox2' => false, // passes if unchecked 1023 | * ]); 1024 | * ?> 1025 | * ``` 1026 | * 1027 | * Pair this with submitForm for quick testing magic. 1028 | * 1029 | * ``` php 1030 | * 'value', 1033 | * 'field2' => 'another value', 1034 | * 'checkbox1' => true, 1035 | * // ... 1036 | * ]; 1037 | * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); 1038 | * // $I->amOnPage('/path/to/form-page') may be needed 1039 | * $I->seeInFormFields('//form[@id=my-form]', $form); 1040 | * ?> 1041 | * ``` 1042 | * 1043 | * @param $formSelector 1044 | * @param $params 1045 | * Conditional Assertion: Test won't be stopped on fail 1046 | * @see \Codeception\Lib\InnerBrowser::seeInFormFields() 1047 | */ 1048 | public function canSeeInFormFields($formSelector, $params) { 1049 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args())); 1050 | } 1051 | /** 1052 | * [!] Method is generated. Documentation taken from corresponding module. 1053 | * 1054 | * Checks if the array of form parameters (name => value) are set on the form matched with the 1055 | * passed selector. 1056 | * 1057 | * ``` php 1058 | * seeInFormFields('form[name=myform]', [ 1060 | * 'input1' => 'value', 1061 | * 'input2' => 'other value', 1062 | * ]); 1063 | * ?> 1064 | * ``` 1065 | * 1066 | * For multi-select elements, or to check values of multiple elements with the same name, an 1067 | * array may be passed: 1068 | * 1069 | * ``` php 1070 | * seeInFormFields('.form-class', [ 1072 | * 'multiselect' => [ 1073 | * 'value1', 1074 | * 'value2', 1075 | * ], 1076 | * 'checkbox[]' => [ 1077 | * 'a checked value', 1078 | * 'another checked value', 1079 | * ], 1080 | * ]); 1081 | * ?> 1082 | * ``` 1083 | * 1084 | * Additionally, checkbox values can be checked with a boolean. 1085 | * 1086 | * ``` php 1087 | * seeInFormFields('#form-id', [ 1089 | * 'checkbox1' => true, // passes if checked 1090 | * 'checkbox2' => false, // passes if unchecked 1091 | * ]); 1092 | * ?> 1093 | * ``` 1094 | * 1095 | * Pair this with submitForm for quick testing magic. 1096 | * 1097 | * ``` php 1098 | * 'value', 1101 | * 'field2' => 'another value', 1102 | * 'checkbox1' => true, 1103 | * // ... 1104 | * ]; 1105 | * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); 1106 | * // $I->amOnPage('/path/to/form-page') may be needed 1107 | * $I->seeInFormFields('//form[@id=my-form]', $form); 1108 | * ?> 1109 | * ``` 1110 | * 1111 | * @param $formSelector 1112 | * @param $params 1113 | * @see \Codeception\Lib\InnerBrowser::seeInFormFields() 1114 | */ 1115 | public function seeInFormFields($formSelector, $params) { 1116 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args())); 1117 | } 1118 | 1119 | 1120 | /** 1121 | * [!] Method is generated. Documentation taken from corresponding module. 1122 | * 1123 | * Checks if the array of form parameters (name => value) are not set on the form matched with 1124 | * the passed selector. 1125 | * 1126 | * ``` php 1127 | * dontSeeInFormFields('form[name=myform]', [ 1129 | * 'input1' => 'non-existent value', 1130 | * 'input2' => 'other non-existent value', 1131 | * ]); 1132 | * ?> 1133 | * ``` 1134 | * 1135 | * To check that an element hasn't been assigned any one of many values, an array can be passed 1136 | * as the value: 1137 | * 1138 | * ``` php 1139 | * dontSeeInFormFields('.form-class', [ 1141 | * 'fieldName' => [ 1142 | * 'This value shouldn\'t be set', 1143 | * 'And this value shouldn\'t be set', 1144 | * ], 1145 | * ]); 1146 | * ?> 1147 | * ``` 1148 | * 1149 | * Additionally, checkbox values can be checked with a boolean. 1150 | * 1151 | * ``` php 1152 | * dontSeeInFormFields('#form-id', [ 1154 | * 'checkbox1' => true, // fails if checked 1155 | * 'checkbox2' => false, // fails if unchecked 1156 | * ]); 1157 | * ?> 1158 | * ``` 1159 | * 1160 | * @param $formSelector 1161 | * @param $params 1162 | * Conditional Assertion: Test won't be stopped on fail 1163 | * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() 1164 | */ 1165 | public function cantSeeInFormFields($formSelector, $params) { 1166 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args())); 1167 | } 1168 | /** 1169 | * [!] Method is generated. Documentation taken from corresponding module. 1170 | * 1171 | * Checks if the array of form parameters (name => value) are not set on the form matched with 1172 | * the passed selector. 1173 | * 1174 | * ``` php 1175 | * dontSeeInFormFields('form[name=myform]', [ 1177 | * 'input1' => 'non-existent value', 1178 | * 'input2' => 'other non-existent value', 1179 | * ]); 1180 | * ?> 1181 | * ``` 1182 | * 1183 | * To check that an element hasn't been assigned any one of many values, an array can be passed 1184 | * as the value: 1185 | * 1186 | * ``` php 1187 | * dontSeeInFormFields('.form-class', [ 1189 | * 'fieldName' => [ 1190 | * 'This value shouldn\'t be set', 1191 | * 'And this value shouldn\'t be set', 1192 | * ], 1193 | * ]); 1194 | * ?> 1195 | * ``` 1196 | * 1197 | * Additionally, checkbox values can be checked with a boolean. 1198 | * 1199 | * ``` php 1200 | * dontSeeInFormFields('#form-id', [ 1202 | * 'checkbox1' => true, // fails if checked 1203 | * 'checkbox2' => false, // fails if unchecked 1204 | * ]); 1205 | * ?> 1206 | * ``` 1207 | * 1208 | * @param $formSelector 1209 | * @param $params 1210 | * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() 1211 | */ 1212 | public function dontSeeInFormFields($formSelector, $params) { 1213 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInFormFields', func_get_args())); 1214 | } 1215 | 1216 | 1217 | /** 1218 | * [!] Method is generated. Documentation taken from corresponding module. 1219 | * 1220 | * Submits the given form on the page, optionally with the given form 1221 | * values. Pass the form field's values as an array in the second 1222 | * parameter. 1223 | * 1224 | * Although this function can be used as a short-hand version of 1225 | * `fillField()`, `selectOption()`, `click()` etc. it has some important 1226 | * differences: 1227 | * 1228 | * * Only field *names* may be used, not CSS/XPath selectors nor field labels 1229 | * * If a field is sent to this function that does *not* exist on the page, 1230 | * it will silently be added to the HTTP request. This is helpful for testing 1231 | * some types of forms, but be aware that you will *not* get an exception 1232 | * like you would if you called `fillField()` or `selectOption()` with 1233 | * a missing field. 1234 | * 1235 | * Fields that are not provided will be filled by their values from the page, 1236 | * or from any previous calls to `fillField()`, `selectOption()` etc. 1237 | * You don't need to click the 'Submit' button afterwards. 1238 | * This command itself triggers the request to form's action. 1239 | * 1240 | * You can optionally specify which button's value to include 1241 | * in the request with the last parameter (as an alternative to 1242 | * explicitly setting its value in the second parameter), as 1243 | * button values are not otherwise included in the request. 1244 | * 1245 | * Examples: 1246 | * 1247 | * ``` php 1248 | * submitForm('#login', [ 1250 | * 'login' => 'davert', 1251 | * 'password' => '123456' 1252 | * ]); 1253 | * // or 1254 | * $I->submitForm('#login', [ 1255 | * 'login' => 'davert', 1256 | * 'password' => '123456' 1257 | * ], 'submitButtonName'); 1258 | * 1259 | * ``` 1260 | * 1261 | * For example, given this sample "Sign Up" form: 1262 | * 1263 | * ``` html 1264 | *
1265 | * Login: 1266 | *
1267 | * Password: 1268 | *
1269 | * Do you agree to our terms? 1270 | *
1271 | * Select pricing plan: 1272 | * 1276 | * 1277 | *
1278 | * ``` 1279 | * 1280 | * You could write the following to submit it: 1281 | * 1282 | * ``` php 1283 | * submitForm( 1285 | * '#userForm', 1286 | * [ 1287 | * 'user' => [ 1288 | * 'login' => 'Davert', 1289 | * 'password' => '123456', 1290 | * 'agree' => true 1291 | * ] 1292 | * ], 1293 | * 'submitButton' 1294 | * ); 1295 | * ``` 1296 | * Note that "2" will be the submitted value for the "plan" field, as it is 1297 | * the selected option. 1298 | * 1299 | * You can also emulate a JavaScript submission by not specifying any 1300 | * buttons in the third parameter to submitForm. 1301 | * 1302 | * ```php 1303 | * submitForm( 1305 | * '#userForm', 1306 | * [ 1307 | * 'user' => [ 1308 | * 'login' => 'Davert', 1309 | * 'password' => '123456', 1310 | * 'agree' => true 1311 | * ] 1312 | * ] 1313 | * ); 1314 | * ``` 1315 | * 1316 | * This function works well when paired with `seeInFormFields()` 1317 | * for quickly testing CRUD interfaces and form validation logic. 1318 | * 1319 | * ``` php 1320 | * 'value', 1323 | * 'field2' => 'another value', 1324 | * 'checkbox1' => true, 1325 | * // ... 1326 | * ]; 1327 | * $I->submitForm('#my-form', $form, 'submitButton'); 1328 | * // $I->amOnPage('/path/to/form-page') may be needed 1329 | * $I->seeInFormFields('#my-form', $form); 1330 | * ``` 1331 | * 1332 | * Parameter values can be set to arrays for multiple input fields 1333 | * of the same name, or multi-select combo boxes. For checkboxes, 1334 | * you can use either the string value or boolean `true`/`false` which will 1335 | * be replaced by the checkbox's value in the DOM. 1336 | * 1337 | * ``` php 1338 | * submitForm('#my-form', [ 1340 | * 'field1' => 'value', 1341 | * 'checkbox' => [ 1342 | * 'value of first checkbox', 1343 | * 'value of second checkbox', 1344 | * ], 1345 | * 'otherCheckboxes' => [ 1346 | * true, 1347 | * false, 1348 | * false 1349 | * ], 1350 | * 'multiselect' => [ 1351 | * 'first option value', 1352 | * 'second option value' 1353 | * ] 1354 | * ]); 1355 | * ``` 1356 | * 1357 | * Mixing string and boolean values for a checkbox's value is not supported 1358 | * and may produce unexpected results. 1359 | * 1360 | * Field names ending in `[]` must be passed without the trailing square 1361 | * bracket characters, and must contain an array for its value. This allows 1362 | * submitting multiple values with the same name, consider: 1363 | * 1364 | * ```php 1365 | * submitForm('#my-form', [ 1368 | * 'field[]' => 'value', 1369 | * 'field[]' => 'another value', // 'field[]' is already a defined key 1370 | * ]); 1371 | * ``` 1372 | * 1373 | * The solution is to pass an array value: 1374 | * 1375 | * ```php 1376 | * submitForm('#my-form', [ 1379 | * 'field' => [ 1380 | * 'value', 1381 | * 'another value', 1382 | * ] 1383 | * ]); 1384 | * ``` 1385 | * 1386 | * @param $selector 1387 | * @param $params 1388 | * @param $button 1389 | * @see \Codeception\Lib\InnerBrowser::submitForm() 1390 | */ 1391 | public function submitForm($selector, $params, $button = null) { 1392 | return $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); 1393 | } 1394 | 1395 | 1396 | /** 1397 | * [!] Method is generated. Documentation taken from corresponding module. 1398 | * 1399 | * Fills a text field or textarea with the given string. 1400 | * 1401 | * ``` php 1402 | * fillField("//input[@type='text']", "Hello World!"); 1404 | * $I->fillField(['name' => 'email'], 'jon@mail.com'); 1405 | * ?> 1406 | * ``` 1407 | * 1408 | * @param $field 1409 | * @param $value 1410 | * @see \Codeception\Lib\InnerBrowser::fillField() 1411 | */ 1412 | public function fillField($field, $value) { 1413 | return $this->getScenario()->runStep(new \Codeception\Step\Action('fillField', func_get_args())); 1414 | } 1415 | 1416 | 1417 | /** 1418 | * [!] Method is generated. Documentation taken from corresponding module. 1419 | * 1420 | * Selects an option in a select tag or in radio button group. 1421 | * 1422 | * ``` php 1423 | * selectOption('form select[name=account]', 'Premium'); 1425 | * $I->selectOption('form input[name=payment]', 'Monthly'); 1426 | * $I->selectOption('//form/select[@name=account]', 'Monthly'); 1427 | * ?> 1428 | * ``` 1429 | * 1430 | * Provide an array for the second argument to select multiple options: 1431 | * 1432 | * ``` php 1433 | * selectOption('Which OS do you use?', array('Windows','Linux')); 1435 | * ?> 1436 | * ``` 1437 | * 1438 | * Or provide an associative array for the second argument to specifically define which selection method should be used: 1439 | * 1440 | * ``` php 1441 | * selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' 1443 | * $I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' 1444 | * ?> 1445 | * ``` 1446 | * 1447 | * @param $select 1448 | * @param $option 1449 | * @see \Codeception\Lib\InnerBrowser::selectOption() 1450 | */ 1451 | public function selectOption($select, $option) { 1452 | return $this->getScenario()->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); 1453 | } 1454 | 1455 | 1456 | /** 1457 | * [!] Method is generated. Documentation taken from corresponding module. 1458 | * 1459 | * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. 1460 | * 1461 | * ``` php 1462 | * checkOption('#agree'); 1464 | * ?> 1465 | * ``` 1466 | * 1467 | * @param $option 1468 | * @see \Codeception\Lib\InnerBrowser::checkOption() 1469 | */ 1470 | public function checkOption($option) { 1471 | return $this->getScenario()->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); 1472 | } 1473 | 1474 | 1475 | /** 1476 | * [!] Method is generated. Documentation taken from corresponding module. 1477 | * 1478 | * Unticks a checkbox. 1479 | * 1480 | * ``` php 1481 | * uncheckOption('#notify'); 1483 | * ?> 1484 | * ``` 1485 | * 1486 | * @param $option 1487 | * @see \Codeception\Lib\InnerBrowser::uncheckOption() 1488 | */ 1489 | public function uncheckOption($option) { 1490 | return $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); 1491 | } 1492 | 1493 | 1494 | /** 1495 | * [!] Method is generated. Documentation taken from corresponding module. 1496 | * 1497 | * Attaches a file relative to the Codeception data directory to the given file upload field. 1498 | * 1499 | * ``` php 1500 | * attachFile('input[@type="file"]', 'prices.xls'); 1503 | * ?> 1504 | * ``` 1505 | * 1506 | * @param $field 1507 | * @param $filename 1508 | * @see \Codeception\Lib\InnerBrowser::attachFile() 1509 | */ 1510 | public function attachFile($field, $filename) { 1511 | return $this->getScenario()->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); 1512 | } 1513 | 1514 | 1515 | /** 1516 | * [!] Method is generated. Documentation taken from corresponding module. 1517 | * 1518 | * If your page triggers an ajax request, you can perform it manually. 1519 | * This action sends a GET ajax request with specified params. 1520 | * 1521 | * See ->sendAjaxPostRequest for examples. 1522 | * 1523 | * @param $uri 1524 | * @param $params 1525 | * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest() 1526 | */ 1527 | public function sendAjaxGetRequest($uri, $params = null) { 1528 | return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args())); 1529 | } 1530 | 1531 | 1532 | /** 1533 | * [!] Method is generated. Documentation taken from corresponding module. 1534 | * 1535 | * If your page triggers an ajax request, you can perform it manually. 1536 | * This action sends a POST ajax request with specified params. 1537 | * Additional params can be passed as array. 1538 | * 1539 | * Example: 1540 | * 1541 | * Imagine that by clicking checkbox you trigger ajax request which updates user settings. 1542 | * We emulate that click by running this ajax request manually. 1543 | * 1544 | * ``` php 1545 | * sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST 1547 | * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET 1548 | * 1549 | * ``` 1550 | * 1551 | * @param $uri 1552 | * @param $params 1553 | * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() 1554 | */ 1555 | public function sendAjaxPostRequest($uri, $params = null) { 1556 | return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args())); 1557 | } 1558 | 1559 | 1560 | /** 1561 | * [!] Method is generated. Documentation taken from corresponding module. 1562 | * 1563 | * If your page triggers an ajax request, you can perform it manually. 1564 | * This action sends an ajax request with specified method and params. 1565 | * 1566 | * Example: 1567 | * 1568 | * You need to perform an ajax request specifying the HTTP method. 1569 | * 1570 | * ``` php 1571 | * sendAjaxRequest('PUT', '/posts/7', array('title' => 'new title')); 1573 | * 1574 | * ``` 1575 | * 1576 | * @param $method 1577 | * @param $uri 1578 | * @param $params 1579 | * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest() 1580 | */ 1581 | public function sendAjaxRequest($method, $uri, $params = null) { 1582 | return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args())); 1583 | } 1584 | 1585 | 1586 | /** 1587 | * [!] Method is generated. Documentation taken from corresponding module. 1588 | * 1589 | * Finds and returns the text contents of the given element. 1590 | * If a fuzzy locator is used, the element is found using CSS, XPath, 1591 | * and by matching the full page source by regular expression. 1592 | * 1593 | * ``` php 1594 | * grabTextFrom('h1'); 1596 | * $heading = $I->grabTextFrom('descendant-or-self::h1'); 1597 | * $value = $I->grabTextFrom('~ 1599 | * ``` 1600 | * 1601 | * @param $cssOrXPathOrRegex 1602 | * 1603 | * @return mixed 1604 | * @see \Codeception\Lib\InnerBrowser::grabTextFrom() 1605 | */ 1606 | public function grabTextFrom($cssOrXPathOrRegex) { 1607 | return $this->getScenario()->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); 1608 | } 1609 | 1610 | 1611 | /** 1612 | * [!] Method is generated. Documentation taken from corresponding module. 1613 | * 1614 | * Grabs the value of the given attribute value from the given element. 1615 | * Fails if element is not found. 1616 | * 1617 | * ``` php 1618 | * grabAttributeFrom('#tooltip', 'title'); 1620 | * ?> 1621 | * ``` 1622 | * 1623 | * 1624 | * @param $cssOrXpath 1625 | * @param $attribute 1626 | * 1627 | * @return mixed 1628 | * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom() 1629 | */ 1630 | public function grabAttributeFrom($cssOrXpath, $attribute) { 1631 | return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); 1632 | } 1633 | 1634 | 1635 | /** 1636 | * [!] Method is generated. Documentation taken from corresponding module. 1637 | * 1638 | * Grabs either the text content, or attribute values, of nodes 1639 | * matched by $cssOrXpath and returns them as an array. 1640 | * 1641 | * ```html 1642 | * First 1643 | * Second 1644 | * Third 1645 | * ``` 1646 | * 1647 | * ```php 1648 | * grabMultiple('a'); 1651 | * 1652 | * // would return ['#first', '#second', '#third'] 1653 | * $aLinks = $I->grabMultiple('a', 'href'); 1654 | * ?> 1655 | * ``` 1656 | * 1657 | * @param $cssOrXpath 1658 | * @param $attribute 1659 | * @return string[] 1660 | * @see \Codeception\Lib\InnerBrowser::grabMultiple() 1661 | */ 1662 | public function grabMultiple($cssOrXpath, $attribute = null) { 1663 | return $this->getScenario()->runStep(new \Codeception\Step\Action('grabMultiple', func_get_args())); 1664 | } 1665 | 1666 | 1667 | /** 1668 | * [!] Method is generated. Documentation taken from corresponding module. 1669 | * 1670 | * @param $field 1671 | * 1672 | * @return array|mixed|null|string 1673 | * @see \Codeception\Lib\InnerBrowser::grabValueFrom() 1674 | */ 1675 | public function grabValueFrom($field) { 1676 | return $this->getScenario()->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); 1677 | } 1678 | 1679 | 1680 | /** 1681 | * [!] Method is generated. Documentation taken from corresponding module. 1682 | * 1683 | * Sets a cookie with the given name and value. 1684 | * You can set additional cookie params like `domain`, `path`, `expires`, `secure` in array passed as last argument. 1685 | * 1686 | * ``` php 1687 | * setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3'); 1689 | * ?> 1690 | * ``` 1691 | * 1692 | * @param $name 1693 | * @param $val 1694 | * @param array $params 1695 | * 1696 | * @return mixed 1697 | * @see \Codeception\Lib\InnerBrowser::setCookie() 1698 | */ 1699 | public function setCookie($name, $val, $params = null) { 1700 | return $this->getScenario()->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); 1701 | } 1702 | 1703 | 1704 | /** 1705 | * [!] Method is generated. Documentation taken from corresponding module. 1706 | * 1707 | * Grabs a cookie value. 1708 | * You can set additional cookie params like `domain`, `path` in array passed as last argument. 1709 | * 1710 | * @param $cookie 1711 | * 1712 | * @param array $params 1713 | * @return mixed 1714 | * @see \Codeception\Lib\InnerBrowser::grabCookie() 1715 | */ 1716 | public function grabCookie($cookie, $params = null) { 1717 | return $this->getScenario()->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); 1718 | } 1719 | 1720 | 1721 | /** 1722 | * [!] Method is generated. Documentation taken from corresponding module. 1723 | * 1724 | * Grabs current page source code. 1725 | * 1726 | * @throws ModuleException if no page was opened. 1727 | * 1728 | * @return string Current page source code. 1729 | * @see \Codeception\Lib\InnerBrowser::grabPageSource() 1730 | */ 1731 | public function grabPageSource() { 1732 | return $this->getScenario()->runStep(new \Codeception\Step\Action('grabPageSource', func_get_args())); 1733 | } 1734 | 1735 | 1736 | /** 1737 | * [!] Method is generated. Documentation taken from corresponding module. 1738 | * 1739 | * Checks that a cookie with the given name is set. 1740 | * You can set additional cookie params like `domain`, `path` as array passed in last argument. 1741 | * 1742 | * ``` php 1743 | * seeCookie('PHPSESSID'); 1745 | * ?> 1746 | * ``` 1747 | * 1748 | * @param $cookie 1749 | * @param array $params 1750 | * @return mixed 1751 | * Conditional Assertion: Test won't be stopped on fail 1752 | * @see \Codeception\Lib\InnerBrowser::seeCookie() 1753 | */ 1754 | public function canSeeCookie($cookie, $params = null) { 1755 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); 1756 | } 1757 | /** 1758 | * [!] Method is generated. Documentation taken from corresponding module. 1759 | * 1760 | * Checks that a cookie with the given name is set. 1761 | * You can set additional cookie params like `domain`, `path` as array passed in last argument. 1762 | * 1763 | * ``` php 1764 | * seeCookie('PHPSESSID'); 1766 | * ?> 1767 | * ``` 1768 | * 1769 | * @param $cookie 1770 | * @param array $params 1771 | * @return mixed 1772 | * @see \Codeception\Lib\InnerBrowser::seeCookie() 1773 | */ 1774 | public function seeCookie($cookie, $params = null) { 1775 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); 1776 | } 1777 | 1778 | 1779 | /** 1780 | * [!] Method is generated. Documentation taken from corresponding module. 1781 | * 1782 | * Checks that there isn't a cookie with the given name. 1783 | * You can set additional cookie params like `domain`, `path` as array passed in last argument. 1784 | * 1785 | * @param $cookie 1786 | * 1787 | * @param array $params 1788 | * @return mixed 1789 | * Conditional Assertion: Test won't be stopped on fail 1790 | * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() 1791 | */ 1792 | public function cantSeeCookie($cookie, $params = null) { 1793 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); 1794 | } 1795 | /** 1796 | * [!] Method is generated. Documentation taken from corresponding module. 1797 | * 1798 | * Checks that there isn't a cookie with the given name. 1799 | * You can set additional cookie params like `domain`, `path` as array passed in last argument. 1800 | * 1801 | * @param $cookie 1802 | * 1803 | * @param array $params 1804 | * @return mixed 1805 | * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() 1806 | */ 1807 | public function dontSeeCookie($cookie, $params = null) { 1808 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); 1809 | } 1810 | 1811 | 1812 | /** 1813 | * [!] Method is generated. Documentation taken from corresponding module. 1814 | * 1815 | * Unsets cookie with the given name. 1816 | * You can set additional cookie params like `domain`, `path` in array passed as last argument. 1817 | * 1818 | * @param $cookie 1819 | * 1820 | * @param array $params 1821 | * @return mixed 1822 | * @see \Codeception\Lib\InnerBrowser::resetCookie() 1823 | */ 1824 | public function resetCookie($name, $params = null) { 1825 | return $this->getScenario()->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); 1826 | } 1827 | 1828 | 1829 | /** 1830 | * [!] Method is generated. Documentation taken from corresponding module. 1831 | * 1832 | * Checks that the given element exists on the page and is visible. 1833 | * You can also specify expected attributes of this element. 1834 | * 1835 | * ``` php 1836 | * seeElement('.error'); 1838 | * $I->seeElement('//form/input[1]'); 1839 | * $I->seeElement('input', ['name' => 'login']); 1840 | * $I->seeElement('input', ['value' => '123456']); 1841 | * 1842 | * // strict locator in first arg, attributes in second 1843 | * $I->seeElement(['css' => 'form input'], ['name' => 'login']); 1844 | * ?> 1845 | * ``` 1846 | * 1847 | * @param $selector 1848 | * @param array $attributes 1849 | * @return 1850 | * Conditional Assertion: Test won't be stopped on fail 1851 | * @see \Codeception\Lib\InnerBrowser::seeElement() 1852 | */ 1853 | public function canSeeElement($selector, $attributes = null) { 1854 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); 1855 | } 1856 | /** 1857 | * [!] Method is generated. Documentation taken from corresponding module. 1858 | * 1859 | * Checks that the given element exists on the page and is visible. 1860 | * You can also specify expected attributes of this element. 1861 | * 1862 | * ``` php 1863 | * seeElement('.error'); 1865 | * $I->seeElement('//form/input[1]'); 1866 | * $I->seeElement('input', ['name' => 'login']); 1867 | * $I->seeElement('input', ['value' => '123456']); 1868 | * 1869 | * // strict locator in first arg, attributes in second 1870 | * $I->seeElement(['css' => 'form input'], ['name' => 'login']); 1871 | * ?> 1872 | * ``` 1873 | * 1874 | * @param $selector 1875 | * @param array $attributes 1876 | * @return 1877 | * @see \Codeception\Lib\InnerBrowser::seeElement() 1878 | */ 1879 | public function seeElement($selector, $attributes = null) { 1880 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); 1881 | } 1882 | 1883 | 1884 | /** 1885 | * [!] Method is generated. Documentation taken from corresponding module. 1886 | * 1887 | * Checks that the given element is invisible or not present on the page. 1888 | * You can also specify expected attributes of this element. 1889 | * 1890 | * ``` php 1891 | * dontSeeElement('.error'); 1893 | * $I->dontSeeElement('//form/input[1]'); 1894 | * $I->dontSeeElement('input', ['name' => 'login']); 1895 | * $I->dontSeeElement('input', ['value' => '123456']); 1896 | * ?> 1897 | * ``` 1898 | * 1899 | * @param $selector 1900 | * @param array $attributes 1901 | * Conditional Assertion: Test won't be stopped on fail 1902 | * @see \Codeception\Lib\InnerBrowser::dontSeeElement() 1903 | */ 1904 | public function cantSeeElement($selector, $attributes = null) { 1905 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); 1906 | } 1907 | /** 1908 | * [!] Method is generated. Documentation taken from corresponding module. 1909 | * 1910 | * Checks that the given element is invisible or not present on the page. 1911 | * You can also specify expected attributes of this element. 1912 | * 1913 | * ``` php 1914 | * dontSeeElement('.error'); 1916 | * $I->dontSeeElement('//form/input[1]'); 1917 | * $I->dontSeeElement('input', ['name' => 'login']); 1918 | * $I->dontSeeElement('input', ['value' => '123456']); 1919 | * ?> 1920 | * ``` 1921 | * 1922 | * @param $selector 1923 | * @param array $attributes 1924 | * @see \Codeception\Lib\InnerBrowser::dontSeeElement() 1925 | */ 1926 | public function dontSeeElement($selector, $attributes = null) { 1927 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); 1928 | } 1929 | 1930 | 1931 | /** 1932 | * [!] Method is generated. Documentation taken from corresponding module. 1933 | * 1934 | * Checks that there are a certain number of elements matched by the given locator on the page. 1935 | * 1936 | * ``` php 1937 | * seeNumberOfElements('tr', 10); 1939 | * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements 1940 | * ?> 1941 | * ``` 1942 | * @param $selector 1943 | * @param mixed $expected : 1944 | * - string: strict number 1945 | * - array: range of numbers [0,10] 1946 | * Conditional Assertion: Test won't be stopped on fail 1947 | * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() 1948 | */ 1949 | public function canSeeNumberOfElements($selector, $expected) { 1950 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args())); 1951 | } 1952 | /** 1953 | * [!] Method is generated. Documentation taken from corresponding module. 1954 | * 1955 | * Checks that there are a certain number of elements matched by the given locator on the page. 1956 | * 1957 | * ``` php 1958 | * seeNumberOfElements('tr', 10); 1960 | * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements 1961 | * ?> 1962 | * ``` 1963 | * @param $selector 1964 | * @param mixed $expected : 1965 | * - string: strict number 1966 | * - array: range of numbers [0,10] 1967 | * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() 1968 | */ 1969 | public function seeNumberOfElements($selector, $expected) { 1970 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElements', func_get_args())); 1971 | } 1972 | 1973 | 1974 | /** 1975 | * [!] Method is generated. Documentation taken from corresponding module. 1976 | * 1977 | * Checks that the given option is selected. 1978 | * 1979 | * ``` php 1980 | * seeOptionIsSelected('#form input[name=payment]', 'Visa'); 1982 | * ?> 1983 | * ``` 1984 | * 1985 | * @param $selector 1986 | * @param $optionText 1987 | * 1988 | * @return mixed 1989 | * Conditional Assertion: Test won't be stopped on fail 1990 | * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() 1991 | */ 1992 | public function canSeeOptionIsSelected($selector, $optionText) { 1993 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args())); 1994 | } 1995 | /** 1996 | * [!] Method is generated. Documentation taken from corresponding module. 1997 | * 1998 | * Checks that the given option is selected. 1999 | * 2000 | * ``` php 2001 | * seeOptionIsSelected('#form input[name=payment]', 'Visa'); 2003 | * ?> 2004 | * ``` 2005 | * 2006 | * @param $selector 2007 | * @param $optionText 2008 | * 2009 | * @return mixed 2010 | * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() 2011 | */ 2012 | public function seeOptionIsSelected($selector, $optionText) { 2013 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args())); 2014 | } 2015 | 2016 | 2017 | /** 2018 | * [!] Method is generated. Documentation taken from corresponding module. 2019 | * 2020 | * Checks that the given option is not selected. 2021 | * 2022 | * ``` php 2023 | * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); 2025 | * ?> 2026 | * ``` 2027 | * 2028 | * @param $selector 2029 | * @param $optionText 2030 | * 2031 | * @return mixed 2032 | * Conditional Assertion: Test won't be stopped on fail 2033 | * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() 2034 | */ 2035 | public function cantSeeOptionIsSelected($selector, $optionText) { 2036 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args())); 2037 | } 2038 | /** 2039 | * [!] Method is generated. Documentation taken from corresponding module. 2040 | * 2041 | * Checks that the given option is not selected. 2042 | * 2043 | * ``` php 2044 | * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); 2046 | * ?> 2047 | * ``` 2048 | * 2049 | * @param $selector 2050 | * @param $optionText 2051 | * 2052 | * @return mixed 2053 | * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() 2054 | */ 2055 | public function dontSeeOptionIsSelected($selector, $optionText) { 2056 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); 2057 | } 2058 | 2059 | 2060 | /** 2061 | * [!] Method is generated. Documentation taken from corresponding module. 2062 | * 2063 | * Asserts that current page has 404 response status code. 2064 | * Conditional Assertion: Test won't be stopped on fail 2065 | * @see \Codeception\Lib\InnerBrowser::seePageNotFound() 2066 | */ 2067 | public function canSeePageNotFound() { 2068 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args())); 2069 | } 2070 | /** 2071 | * [!] Method is generated. Documentation taken from corresponding module. 2072 | * 2073 | * Asserts that current page has 404 response status code. 2074 | * @see \Codeception\Lib\InnerBrowser::seePageNotFound() 2075 | */ 2076 | public function seePageNotFound() { 2077 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args())); 2078 | } 2079 | 2080 | 2081 | /** 2082 | * [!] Method is generated. Documentation taken from corresponding module. 2083 | * 2084 | * Checks that response code is equal to value provided. 2085 | * 2086 | * ```php 2087 | * seeResponseCodeIs(200); 2089 | * 2090 | * // recommended \Codeception\Util\HttpCode 2091 | * $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); 2092 | * ``` 2093 | * 2094 | * @param $code 2095 | * Conditional Assertion: Test won't be stopped on fail 2096 | * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() 2097 | */ 2098 | public function canSeeResponseCodeIs($code) { 2099 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args())); 2100 | } 2101 | /** 2102 | * [!] Method is generated. Documentation taken from corresponding module. 2103 | * 2104 | * Checks that response code is equal to value provided. 2105 | * 2106 | * ```php 2107 | * seeResponseCodeIs(200); 2109 | * 2110 | * // recommended \Codeception\Util\HttpCode 2111 | * $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); 2112 | * ``` 2113 | * 2114 | * @param $code 2115 | * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() 2116 | */ 2117 | public function seeResponseCodeIs($code) { 2118 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args())); 2119 | } 2120 | 2121 | 2122 | /** 2123 | * [!] Method is generated. Documentation taken from corresponding module. 2124 | * 2125 | * Checks that response code is equal to value provided. 2126 | * 2127 | * ```php 2128 | * dontSeeResponseCodeIs(200); 2130 | * 2131 | * // recommended \Codeception\Util\HttpCode 2132 | * $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK); 2133 | * ``` 2134 | * @param $code 2135 | * Conditional Assertion: Test won't be stopped on fail 2136 | * @see \Codeception\Lib\InnerBrowser::dontSeeResponseCodeIs() 2137 | */ 2138 | public function cantSeeResponseCodeIs($code) { 2139 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeResponseCodeIs', func_get_args())); 2140 | } 2141 | /** 2142 | * [!] Method is generated. Documentation taken from corresponding module. 2143 | * 2144 | * Checks that response code is equal to value provided. 2145 | * 2146 | * ```php 2147 | * dontSeeResponseCodeIs(200); 2149 | * 2150 | * // recommended \Codeception\Util\HttpCode 2151 | * $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK); 2152 | * ``` 2153 | * @param $code 2154 | * @see \Codeception\Lib\InnerBrowser::dontSeeResponseCodeIs() 2155 | */ 2156 | public function dontSeeResponseCodeIs($code) { 2157 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeResponseCodeIs', func_get_args())); 2158 | } 2159 | 2160 | 2161 | /** 2162 | * [!] Method is generated. Documentation taken from corresponding module. 2163 | * 2164 | * Checks that the page title contains the given string. 2165 | * 2166 | * ``` php 2167 | * seeInTitle('Blog - Post #1'); 2169 | * ?> 2170 | * ``` 2171 | * 2172 | * @param $title 2173 | * 2174 | * @return mixed 2175 | * Conditional Assertion: Test won't be stopped on fail 2176 | * @see \Codeception\Lib\InnerBrowser::seeInTitle() 2177 | */ 2178 | public function canSeeInTitle($title) { 2179 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); 2180 | } 2181 | /** 2182 | * [!] Method is generated. Documentation taken from corresponding module. 2183 | * 2184 | * Checks that the page title contains the given string. 2185 | * 2186 | * ``` php 2187 | * seeInTitle('Blog - Post #1'); 2189 | * ?> 2190 | * ``` 2191 | * 2192 | * @param $title 2193 | * 2194 | * @return mixed 2195 | * @see \Codeception\Lib\InnerBrowser::seeInTitle() 2196 | */ 2197 | public function seeInTitle($title) { 2198 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args())); 2199 | } 2200 | 2201 | 2202 | /** 2203 | * [!] Method is generated. Documentation taken from corresponding module. 2204 | * 2205 | * Checks that the page title does not contain the given string. 2206 | * 2207 | * @param $title 2208 | * 2209 | * @return mixed 2210 | * Conditional Assertion: Test won't be stopped on fail 2211 | * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() 2212 | */ 2213 | public function cantSeeInTitle($title) { 2214 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args())); 2215 | } 2216 | /** 2217 | * [!] Method is generated. Documentation taken from corresponding module. 2218 | * 2219 | * Checks that the page title does not contain the given string. 2220 | * 2221 | * @param $title 2222 | * 2223 | * @return mixed 2224 | * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() 2225 | */ 2226 | public function dontSeeInTitle($title) { 2227 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); 2228 | } 2229 | 2230 | 2231 | /** 2232 | * [!] Method is generated. Documentation taken from corresponding module. 2233 | * 2234 | * Switch to iframe or frame on the page. 2235 | * 2236 | * Example: 2237 | * ``` html 2238 | *