├── .gitignore ├── .travis.yml ├── LICENSE.md ├── README.md ├── Wordpress.php ├── codeception.yml ├── composer.json └── tests ├── _bootstrap.php ├── _data └── .gitignore ├── _output └── .gitignore ├── _support ├── AcceptanceHelper.php ├── FunctionalHelper.php └── UnitHelper.php ├── acceptance.suite.yml ├── acceptance ├── AcceptanceTester.php └── _bootstrap.php ├── functional.suite.yml ├── functional ├── FunctionalTester.php └── _bootstrap.php ├── unit.suite.yml └── unit ├── UnitTester.php └── _bootstrap.php /.gitignore: -------------------------------------------------------------------------------- 1 | #==============================================================# 2 | # Composer dependencies are used for development comfort only. # 3 | # They should always be ignored in the repository. # 4 | #=============================================================== 5 | 6 | .idea/ 7 | vendor/ 8 | composer.lock -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.4 5 | - 5.5 6 | - 5.6 7 | 8 | install: 9 | - composer self-update && composer --version 10 | - composer global require "fxp/composer-asset-plugin:1.0.0-beta3" 11 | - composer install 12 | 13 | script: 14 | - php vendor/bin/codecept run -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Monitor Backlinks Ltd. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repository is no longer maintained. 2 | Issue reports and pull requests will not be attended. You are welcome to fork the repository if you'd like though. 3 | ============== 4 | 5 | Yii2 Wordpress 6 | ============== 7 | 8 | [Yii2 Wordpress](http://monitorbacklinks.github.io/yii2-wordpress) is a component for [Yii2 framework](https://github.com/yiisoft/yii2) designed for integration with Wordpress CMS via XML-RPC API. 9 | 10 | This component is built on top of [Wordpress XML-RPC PHP Client](https://github.com/letrunghieu/wordpress-xmlrpc-client) by [Hieu Le Trung](https://github.com/letrunghieu). 11 | 12 | [![Latest Stable Version](https://poser.pugx.org/monitorbacklinks/yii2-wordpress/v/stable.svg)](https://packagist.org/packages/monitorbacklinks/yii2-wordpress) 13 | [![Build Status](https://travis-ci.org/monitorbacklinks/yii2-wordpress.svg?branch=master)](https://travis-ci.org/monitorbacklinks/yii2-wordpress) 14 | [![Code Climate](https://codeclimate.com/github/monitorbacklinks/yii2-wordpress.png)](https://codeclimate.com/github/monitorbacklinks/yii2-wordpress) 15 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/monitorbacklinks/yii2-wordpress/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/monitorbacklinks/yii2-wordpress/?branch=master) 16 | [![Version Eye](https://www.versioneye.com/php/monitorbacklinks:yii2-wordpress/badge.svg)](https://www.versioneye.com/php/monitorbacklinks:yii2-wordpress) 17 | [![License](https://poser.pugx.org/monitorbacklinks/yii2-wordpress/license.svg)](https://packagist.org/packages/monitorbacklinks/yii2-wordpress) 18 | 19 | ## Requirements 20 | 21 | - Yii 2.0 22 | - PHP 5.4 23 | - PHP extension [XML-RPC](http://php.net//manual/en/book.xmlrpc.php) 24 | 25 | ## Installation 26 | 27 | The preferred way to install this extension is through [Composer](http://getcomposer.org/). 28 | 29 | Either run 30 | 31 | ``` php composer.phar require monitorbacklinks/yii2-wordpress "dev-master" ``` 32 | 33 | or add 34 | 35 | ``` "monitorbacklinks/yii2-wordpress": "dev-master"``` 36 | 37 | to the `require` section of your `composer.json` file. 38 | 39 | 40 | ## Usage 41 | 42 | ### Component creation 43 | 44 | In order to use this extension, first thing you need to do is to create a `blog` (you can change the name if you want) 45 | component and configure it. Here is the example of minimal configuration (in your `config/main.php`): 46 | 47 | ```php 48 | 'components' => [ 49 | ... 50 | 'blog' => [ 51 | 'class' => '\monitorbacklinks\yii2wp\Wordpress', 52 | 'endpoint' => 'http://example.com/xmlrpc.php', 53 | 'username' => 'demo', 54 | 'password' => 'demo' 55 | ] 56 | ... 57 | ] 58 | ``` 59 | 60 | ### First API request 61 | 62 | When component is configured, you can start making requests to your Wordpress site. 63 | 64 | For example, get ten latest published posts. Select `guid`, `post_title` and `post_content` fields only: 65 | 66 | ```php 67 | $blogPosts = Yii::$app->blog->getPosts([ 68 | 'post_status' => 'publish', 69 | 'number' => 10 70 | ], ['guid', 'post_title', 'post_content']); 71 | ``` 72 | 73 | Or create a new post with title "New post" and content "Hello world!": 74 | 75 | ```php 76 | $postID = Yii::$app->blog->newPost('New post', 'Hello world!'); 77 | ``` 78 | 79 | ### Caching request results 80 | 81 | Making API calls to an external application means delays. 82 | If you don't want your users to wait for a Wordpress response each time, caching is a right thing to do: 83 | 84 | ```php 85 | // The user profile will be fetched from cache if available. 86 | // If not, the query will be made against XML-RPC API and cached for use next time. 87 | $profile = Yii::$app->blog->cache(function (Wordpress $blog) { 88 | return $blog->getProfile(); 89 | }); 90 | ``` 91 | 92 | In case, if you need something more complex, you can disable caching for some requests: 93 | 94 | ```php 95 | $blogPosts = Yii::$app->blog->cache(function (Wordpress $blog) { 96 | 97 | // ... queries that use query cache ... 98 | 99 | return $blog->noCache(function (Wordpress $blog) { 100 | // this query will not use query cache 101 | return $blog->getPosts(); 102 | }); 103 | }); 104 | ``` 105 | 106 | Caching will work for data retrieval queries only. 107 | Queries that create, update or delete records will not use caching component. 108 | 109 | 110 | ## Configuration parameters 111 | 112 | #### `$endpoint` 113 | 114 | `string` Wordpress XML-RPC API endpoint URL. 115 | 116 | #### `$username` 117 | 118 | `string` Wordpress authentication username. 119 | 120 | Please note, that any actions made by XML-RPC will be made on behalf of this user. 121 | 122 | #### `$password` 123 | 124 | `string` Wordpress authentication password. 125 | 126 | #### `$proxyConfig` 127 | 128 | `array` Proxy server configuration. 129 | 130 | This configuration array should follow the following format: 131 | 132 | - `proxy_ip`: the ip of the proxy server (WITHOUT port) 133 | - `proxy_port`: the port of the proxy server 134 | - `proxy_user`: the username for proxy authorization 135 | - `proxy_pass`: the password for proxy authorization 136 | - `proxy_mode`: value for CURLOPT_PROXYAUTH option (default to CURLAUTH_BASIC) 137 | 138 | Empty array means that no proxy should be used. 139 | 140 | Default value: `[]`. 141 | 142 | #### `$authConfig` 143 | 144 | `array` Server HTTP authentication configuration. 145 | 146 | This configuration array should follow the following format: 147 | 148 | - `auth_user`: the username for server authentication 149 | - `auth_pass`: the password for server authentication 150 | - `auth_mode`: value for CURLOPT_HTTPAUTH option (default to CURLAUTH_BASIC) 151 | 152 | Empty array means that no HTTP authentication should be used. 153 | 154 | Default value: `[]`. 155 | 156 | #### `$catchExceptions` 157 | 158 | `boolean` Whether to catch exceptions thrown by Wordpress API, pass them to the log and return default value, 159 | or transmit them further along the call chain. 160 | 161 | Default value: `true`. 162 | 163 | #### `$enableQueryCache` 164 | 165 | `boolean` Whether to enable query caching. 166 | 167 | Default value: `true`. 168 | 169 | #### `$queryCacheDuration` 170 | 171 | `integer` The default number of seconds that query results can remain valid in cache. 172 | 173 | Use 0 to indicate that the cached data will never expire. 174 | 175 | Default value: `3600`. 176 | 177 | #### `$queryCache` 178 | 179 | `Cache|string` The cache object or the ID of the cache application component that is used for query caching. 180 | 181 | Default value: `'cache'`. 182 | 183 | 184 | ## List of available methods 185 | 186 | The full list of available methods can be found in 187 | [Wordpress XML-RPC PHP Client Class Reference](http://letrunghieu.github.io/wordpress-xmlrpc-client/api/class-HieuLe.WordpressXmlrpcClient.WordpressClient.html). 188 | 189 | Please note, that all those methods are throwing an exceptions in case of any errors. 190 | While this extension is configured (by default), in case of errors, to return an empty array for any data retrial 191 | methods and false for any create, update or delete methods. Please see `$catchExceptions` configuration option for details. 192 | 193 | ## Errors logging 194 | 195 | There are a lot of things that can go wrong (network problems, wrong Wordpress user permissions, etc.). 196 | If `$catchExceptions` configuration option is set to `true` (default value), this extension will catch them and pass to 197 | `monitorbacklinks\yii2wp\Wordpress::*` logging category. 198 | 199 | In order to see them, you can configure your Yii2 `log` component to something similar to this: 200 | 201 | ```php 202 | 'components' => [ 203 | ... 204 | 'log' => [ 205 | 'targets' => [ 206 | 'file' => [ 207 | 'class' => 'yii\log\FileTarget', 208 | 'levels' => ['error'], 209 | 'categories' => ['monitorbacklinks\yii2wp\Wordpress::*'], 210 | ], 211 | ], 212 | ], 213 | ... 214 | ] 215 | ``` 216 | 217 | 218 | ## Report 219 | 220 | - Report any issues [on the GitHub](https://github.com/monitorbacklinks/yii2-wordpress/issues). 221 | 222 | 223 | ## License 224 | 225 | **yii2-wordpress** is released under the MIT License. See the bundled `LICENSE.md` for details. 226 | 227 | 228 | ## Resources 229 | 230 | - [Project Page](http://monitorbacklinks.github.io/yii2-wordpress) 231 | - [Packagist Package](https://packagist.org/packages/monitorbacklinks/yii2-wordpress) 232 | - [Source Code](https://github.com/monitorbacklinks/yii2-wordpress) 233 | -------------------------------------------------------------------------------- /Wordpress.php: -------------------------------------------------------------------------------- 1 | 78 | *
  • proxy_ip: the ip of the proxy server (WITHOUT port)
  • 79 | *
  • proxy_port: the port of the proxy server
  • 80 | *
  • proxy_user: the username for proxy authorization
  • 81 | *
  • proxy_pass: the password for proxy authorization
  • 82 | *
  • proxy_mode: value for CURLOPT_PROXYAUTH option (default to CURLAUTH_BASIC)
  • 83 | * 84 | */ 85 | public $proxyConfig = []; 86 | 87 | /** 88 | * @var array $httpAuthConfig HTTP Auth configuration array has these fields: 89 | * 94 | */ 95 | public $httpAuthConfig = []; 96 | 97 | /** 98 | * @var boolean $enableQueryCache Whether to enable query caching. 99 | * Note that in order to enable query caching, a valid cache component as specified by [[queryCache]] must be 100 | * enabled and [[enableQueryCache]] must be set true. 101 | * Also, only the results of the queries enclosed within [[cache()]] will be cached. 102 | * @see $queryCache 103 | * @see cache() 104 | * @see noCache() 105 | */ 106 | public $enableQueryCache = true; 107 | 108 | /** 109 | * @var integer $queryCacheDuration The default number of seconds that query results can remain valid in cache. 110 | * Use 0 to indicate that the cached data will never expire. 111 | * Defaults to 3600, meaning 3600 seconds, or one hour. Use 0 to indicate that the cached data will never expire. 112 | * The value of this property will be used when [[cache()]] is called without a cache duration. 113 | * @see $enableQueryCache 114 | * @see cache() 115 | */ 116 | public $queryCacheDuration = 3600; 117 | 118 | /** 119 | * @var Cache|string $queryCache The cache object or the ID of the cache application component that is used for query caching. 120 | * @see $enableQueryCache 121 | */ 122 | public $queryCache = 'cache'; 123 | 124 | /** 125 | * @var bool $catchExceptions Whether to catch exceptions thrown by Wordpress API, pass them to the log and return 126 | * default value, or transmit them further along the call chain. 127 | */ 128 | public $catchExceptions = true; 129 | 130 | /** 131 | * @var array $methodMap An internal storage for allowed methods and their values in case of error. 132 | * @internal 133 | */ 134 | protected $methodMap = [ 135 | 'getPost' => [], 136 | 'getPosts' => [], 137 | 'newPost' => false, 138 | 'editPost' => false, 139 | 'deletePost' => false, 140 | 'getPostType' => [], 141 | 'getPostTypes' => [], 142 | 'getPostFormats' => [], 143 | 'getPostStatusList' => [], 144 | 'getTaxonomy' => [], 145 | 'getTaxonomies' => [], 146 | 'getTerm' => [], 147 | 'getTerms' => [], 148 | 'newTerm' => false, 149 | 'editTerm' => false, 150 | 'deleteTerm' => false, 151 | 'getMediaItem' => [], 152 | 'getMediaLibrary' => [], 153 | 'uploadFile' => [], 154 | 'getCommentCount' => false, 155 | 'getComment' => [], 156 | 'getComments' => [], 157 | 'newComment' => false, 158 | 'editComment' => false, 159 | 'deleteComment' => false, 160 | 'getCommentStatusList' => [], 161 | 'getOptions' => [], 162 | 'setOptions' => [], 163 | 'getUsersBlogs' => [], 164 | 'getUser' => [], 165 | 'getUsers' => [], 166 | 'getProfile' => [], 167 | 'editProfile' => false, 168 | 'callCustomMethod' => false, 169 | ]; 170 | 171 | /** 172 | * @var array $_queryCacheInfo Query cache parameters for the [[cache()]] calls. 173 | * @see getQueryCacheInfo() 174 | */ 175 | private $_queryCacheInfo = []; 176 | 177 | /** 178 | * @var WordpressClient $_clientInstance Wordpress API client instance. 179 | */ 180 | private $_clientInstance; 181 | 182 | /** 183 | * @inheritdoc 184 | */ 185 | public function init() 186 | { 187 | parent::init(); 188 | 189 | // Validate given parameters 190 | $className = self::className(); 191 | $urlValidator = new UrlValidator([ 192 | 'enableIDN' => extension_loaded('intl') 193 | ]); 194 | if (empty($this->endpoint) || !$urlValidator->validate($this->endpoint)) { 195 | throw new InvalidConfigException("Class \"{$className}\" requires a valid URL to Wordpress XML-RPC API endpoint to be set in \"\$endpoint\" attribute."); 196 | } 197 | if (empty($this->username) || empty($this->password)) { 198 | throw new InvalidConfigException("Class \"{$className}\" requires a valid Wordpress credentials to be set in \"\$username\" and \"\$password\" attributes."); 199 | } 200 | if (!is_array($this->proxyConfig)) { 201 | throw new InvalidConfigException("Class \"{$className}\" requires \"\$proxyConfig\" to be given in array format."); 202 | } 203 | if (!is_array($this->httpAuthConfig)) { 204 | throw new InvalidConfigException("Class \"{$className}\" requires \"\$httpAuthConfig\" to be given in array format."); 205 | } 206 | 207 | // Create API client 208 | $this->_clientInstance = new WordpressClient($this->endpoint, $this->username, $this->password); 209 | $this->_clientInstance->setProxy($this->proxyConfig); 210 | $this->_clientInstance->setAuth($this->httpAuthConfig); 211 | } 212 | 213 | /** 214 | * Calls the named method which is not a class method. 215 | * 216 | * This method will check if Wordpress client has the named method and will execute it if available. 217 | * Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown 218 | * method is being invoked. 219 | * 220 | * @param string $name The method name. 221 | * @param array $params Method parameters. 222 | * 223 | * @throws \Exception If error occurred an $catchExceptions set to false. 224 | * @return mixed The method return value. 225 | */ 226 | public function __call($name, $params) 227 | { 228 | // If method exists 229 | $client = $this->getClient(); 230 | if (method_exists($client, $name) && array_key_exists($name, $this->methodMap) && is_callable([$client, $name])) { 231 | $profile = "Running an XML-RPC API call: {$name}"; 232 | $token = "monitorbacklinks\\yii2wp\\Wordpress::{$name}"; 233 | $dataRetrieval = (strpos($name, 'get') === 0); 234 | try { 235 | 236 | Yii::beginProfile($profile); 237 | 238 | // Initialize cache 239 | $cacheKey = [__CLASS__, $name, $params]; 240 | $info = $this->getQueryCacheInfo(); 241 | if (is_array($info)) { 242 | /* @var $cache \yii\caching\Cache */ 243 | $cache = $info[0]; 244 | } 245 | 246 | // Search result in the cache 247 | if (isset($cache) && $dataRetrieval) { 248 | if (($result = $cache->get($cacheKey)) !== false) { 249 | Yii::trace('Query result served from cache', $token); 250 | Yii::endProfile($profile); 251 | return $result; 252 | } 253 | } 254 | 255 | // Get result and but it to the cache 256 | $result = call_user_func_array([$client, $name], $params); 257 | if (isset($cache) && $dataRetrieval) { 258 | $cache->set($cacheKey, $result, $info[1], $info[2]); 259 | Yii::trace('Saved query result in cache', $token); 260 | } 261 | 262 | Yii::endProfile($profile); 263 | return $result; 264 | 265 | } catch (\Exception $exception) { 266 | Yii::endProfile($profile); 267 | if ($this->catchExceptions) { 268 | Yii::error($exception->getMessage(), $token); 269 | return $this->methodMap[$name]; 270 | } else { 271 | throw $exception; 272 | } 273 | } 274 | } 275 | 276 | return parent::__call($name, $params); 277 | } 278 | 279 | /** 280 | * Get wordpress API client instance. 281 | * 282 | * @return WordpressClient Wordpress API client instance. 283 | */ 284 | public function getClient() 285 | { 286 | return $this->_clientInstance; 287 | } 288 | 289 | /** 290 | * Uses query cache for the queries performed with the callable. 291 | * When query caching is enabled ([[enableQueryCache]] is true and [[queryCache]] refers to a valid cache), 292 | * queries performed within the callable will be cached and their results will be fetched from cache if available. 293 | * For example, 294 | * 295 | * ```php 296 | * // The user profile will be fetched from cache if available. 297 | * // If not, the query will be made against XML-RPC API and cached for use next time. 298 | * $profile = Yii::$app->blog->cache(function (Wordpress $blog) { 299 | * return $blog->getProfile(); 300 | * }); 301 | * ``` 302 | * 303 | * Note that query cache is only meaningful for queries that return results. For queries that create, update or 304 | * delete records, query cache will not be used. 305 | * 306 | * @param callable $callable A PHP callable that contains XML-RPC API queries which will make use of query cache. 307 | * The signature of the callable is `function (Wordpress $blog)`. 308 | * @param integer $duration The number of seconds that query results can remain valid in the cache. If this is 309 | * not set, the value of [[queryCacheDuration]] will be used instead. 310 | * Use 0 to indicate that the cached data will never expire. 311 | * @param \yii\caching\Dependency $dependency The cache dependency associated with the cached query results. 312 | * @return mixed The return result of the callable. 313 | * @throws \Exception If there is any exception during query. 314 | * @see enableQueryCache 315 | * @see queryCache 316 | * @see noCache() 317 | */ 318 | public function cache(callable $callable, $duration = null, $dependency = null) 319 | { 320 | $this->_queryCacheInfo[] = [$duration === null ? $this->queryCacheDuration : $duration, $dependency]; 321 | try { 322 | $result = call_user_func($callable, $this); 323 | array_pop($this->_queryCacheInfo); 324 | return $result; 325 | } catch (\Exception $e) { 326 | array_pop($this->_queryCacheInfo); 327 | throw $e; 328 | } 329 | } 330 | 331 | /** 332 | * Disables query cache temporarily. 333 | * Queries performed within the callable will not use query cache at all. For example, 334 | * 335 | * ```php 336 | * $blogPosts = Yii::$app->blog->cache(function (Wordpress $blog) { 337 | * 338 | * // ... queries that use query cache ... 339 | * 340 | * return $blog->noCache(function (Wordpress $blog) { 341 | * // this query will not use query cache 342 | * return $blog->getPosts(); 343 | * }); 344 | * }); 345 | * ``` 346 | * 347 | * @param callable $callable A PHP callable that contains XML-RPC API queries which should not use query cache. 348 | * The signature of the callable is `function (Wordpress $blog)`. 349 | * @return mixed The return result of the callable. 350 | * @throws \Exception If there is any exception during query. 351 | * @see enableQueryCache 352 | * @see queryCache 353 | * @see cache() 354 | */ 355 | public function noCache(callable $callable) 356 | { 357 | $this->_queryCacheInfo[] = false; 358 | try { 359 | $result = call_user_func($callable, $this); 360 | array_pop($this->_queryCacheInfo); 361 | return $result; 362 | } catch (\Exception $e) { 363 | array_pop($this->_queryCacheInfo); 364 | throw $e; 365 | } 366 | } 367 | 368 | /** 369 | * Returns the current query cache information. 370 | * This method is used internally by [[Wordpress]]. 371 | * @return array The current query cache information, or null if query cache is not enabled. 372 | * @internal 373 | */ 374 | protected function getQueryCacheInfo() 375 | { 376 | $info = end($this->_queryCacheInfo); 377 | if ($this->enableQueryCache) { 378 | if (is_string($this->queryCache) && Yii::$app) { 379 | $cache = Yii::$app->get($this->queryCache, false); 380 | } else { 381 | $cache = $this->queryCache; 382 | } 383 | if ($cache instanceof Cache) { 384 | return is_array($info) ? [$cache, $info[0], $info[1]] : null; 385 | } 386 | } 387 | return null; 388 | } 389 | } 390 | -------------------------------------------------------------------------------- /codeception.yml: -------------------------------------------------------------------------------- 1 | actor: Tester 2 | paths: 3 | tests: tests 4 | log: tests/_output 5 | data: tests/_data 6 | helpers: tests/_support 7 | settings: 8 | bootstrap: _bootstrap.php 9 | colors: true 10 | memory_limit: 1024M -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "monitorbacklinks/yii2-wordpress", 3 | "description": "Yii2 component for integration with Wordpress CMS via XML-RPC API", 4 | "homepage": "http://monitorbacklinks.github.io/yii2-wordpress/", 5 | "keywords": ["yii", "yii2", "wordpress", "xml-rpc", "xmlrpc", "wp", "integration"], 6 | "type": "yii2-extension", 7 | "license": "MIT", 8 | "support": { 9 | "issues": "https://github.com/monitorbacklinks/yii2-wordpress/issues", 10 | "source": "https://github.com/monitorbacklinks/yii2-wordpress" 11 | }, 12 | "authors": [ 13 | { 14 | "name": "Ivan Koptiev", 15 | "email": "ivan@monitorbacklinks.com", 16 | "role": "Developer" 17 | } 18 | ], 19 | "require": { 20 | "php": ">=5.4.0", 21 | "ext-xmlrpc": "*", 22 | "yiisoft/yii2": "*", 23 | "hieu-le/wordpress-xmlrpc-client": "~2.0" 24 | }, 25 | "require-dev": { 26 | "codeception/codeception": "~2.0" 27 | }, 28 | "autoload": { 29 | "psr-4": { 30 | "monitorbacklinks\\yii2wp\\": "" 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /tests/_bootstrap.php: -------------------------------------------------------------------------------- 1 | scenario->runStep(new \Codeception\Step\Action('setHeader', func_get_args())); 35 | } 36 | 37 | 38 | /** 39 | * [!] Method is generated. Documentation taken from corresponding module. 40 | * 41 | * Sets 'url' configuration parameter to hosts subdomain. 42 | * It does not open a page on subdomain. Use `amOnPage` for that 43 | * 44 | * ``` php 45 | * amOnSubdomain('user'); 51 | * $I->amOnPage('/'); 52 | * // moves to http://user.mysite.com/ 53 | * ?> 54 | * ``` 55 | * 56 | * @param $subdomain 57 | * 58 | * @return mixed 59 | * @see \Codeception\Module\PhpBrowser::amOnSubdomain() 60 | */ 61 | public function amOnSubdomain($subdomain) { 62 | return $this->scenario->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args())); 63 | } 64 | 65 | 66 | /** 67 | * [!] Method is generated. Documentation taken from corresponding module. 68 | * 69 | * Low-level API method. 70 | * If Codeception commands are not enough, use [Guzzle HTTP Client](http://guzzlephp.org/) methods directly 71 | * 72 | * Example: 73 | * 74 | * ``` php 75 | * executeInGuzzle(function (\GuzzleHttp\Client $client) { 77 | * $client->get('/get', ['query' => ['foo' => 'bar']]); 78 | * }); 79 | * ?> 80 | * ``` 81 | * 82 | * It is not recommended to use this command on a regular basis. 83 | * If Codeception lacks important Guzzle Client methods, implement them and submit patches. 84 | * 85 | * @param callable $function 86 | * @see \Codeception\Module\PhpBrowser::executeInGuzzle() 87 | */ 88 | public function executeInGuzzle($function) { 89 | return $this->scenario->runStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args())); 90 | } 91 | 92 | 93 | /** 94 | * [!] Method is generated. Documentation taken from corresponding module. 95 | * 96 | * Authenticates user for HTTP_AUTH 97 | * 98 | * @param $username 99 | * @param $password 100 | * @see \Codeception\Lib\InnerBrowser::amHttpAuthenticated() 101 | */ 102 | public function amHttpAuthenticated($username, $password) { 103 | return $this->scenario->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args())); 104 | } 105 | 106 | 107 | /** 108 | * [!] Method is generated. Documentation taken from corresponding module. 109 | * 110 | * Opens the page. 111 | * Requires relative uri as parameter 112 | * 113 | * Example: 114 | * 115 | * ``` php 116 | * amOnPage('/'); 119 | * // opens /register page 120 | * $I->amOnPage('/register'); 121 | * ?> 122 | * ``` 123 | * 124 | * @param $page 125 | * @see \Codeception\Lib\InnerBrowser::amOnPage() 126 | */ 127 | public function amOnPage($page) { 128 | return $this->scenario->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); 129 | } 130 | 131 | 132 | /** 133 | * [!] Method is generated. Documentation taken from corresponding module. 134 | * 135 | * Perform a click on link or button. 136 | * Link or button are found by their names or CSS selector. 137 | * Submits a form if button is a submit type. 138 | * 139 | * If link is an image it's found by alt attribute value of image. 140 | * If button is image button is found by it's value 141 | * If link or button can't be found by name they are searched by CSS selector. 142 | * 143 | * The second parameter is a context: CSS or XPath locator to narrow the search. 144 | * 145 | * Examples: 146 | * 147 | * ``` php 148 | * click('Logout'); 151 | * // button of form 152 | * $I->click('Submit'); 153 | * // CSS button 154 | * $I->click('#form input[type=submit]'); 155 | * // XPath 156 | * $I->click('//form/*[@type=submit]'); 157 | * // link in context 158 | * $I->click('Logout', '#nav'); 159 | * // using strict locator 160 | * $I->click(['link' => 'Login']); 161 | * ?> 162 | * ``` 163 | * 164 | * @param $link 165 | * @param $context 166 | * @see \Codeception\Lib\InnerBrowser::click() 167 | */ 168 | public function click($link, $context = null) { 169 | return $this->scenario->runStep(new \Codeception\Step\Action('click', func_get_args())); 170 | } 171 | 172 | 173 | /** 174 | * [!] Method is generated. Documentation taken from corresponding module. 175 | * 176 | * Check if current page contains the text specified. 177 | * Specify the css selector to match only specific region. 178 | * 179 | * Examples: 180 | * 181 | * ``` php 182 | * see('Logout'); // I can suppose user is logged in 184 | * $I->see('Sign Up','h1'); // I can suppose it's a signup page 185 | * $I->see('Sign Up','//body/h1'); // with XPath 186 | * ?> 187 | * ``` 188 | * 189 | * @param $text 190 | * @param null $selector 191 | * Conditional Assertion: Test won't be stopped on fail 192 | * @see \Codeception\Lib\InnerBrowser::see() 193 | */ 194 | public function canSee($text, $selector = null) { 195 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); 196 | } 197 | /** 198 | * [!] Method is generated. Documentation taken from corresponding module. 199 | * 200 | * Check if current page contains the text specified. 201 | * Specify the css selector to match only specific region. 202 | * 203 | * Examples: 204 | * 205 | * ``` php 206 | * see('Logout'); // I can suppose user is logged in 208 | * $I->see('Sign Up','h1'); // I can suppose it's a signup page 209 | * $I->see('Sign Up','//body/h1'); // with XPath 210 | * ?> 211 | * ``` 212 | * 213 | * @param $text 214 | * @param null $selector 215 | * @see \Codeception\Lib\InnerBrowser::see() 216 | */ 217 | public function see($text, $selector = null) { 218 | return $this->scenario->runStep(new \Codeception\Step\Assertion('see', func_get_args())); 219 | } 220 | 221 | 222 | /** 223 | * [!] Method is generated. Documentation taken from corresponding module. 224 | * 225 | * Check if current page doesn't contain the text specified. 226 | * Specify the css selector to match only specific region. 227 | * 228 | * Examples: 229 | * 230 | * ```php 231 | * dontSee('Login'); // I can suppose user is already logged in 233 | * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page 234 | * $I->dontSee('Sign Up','//body/h1'); // with XPath 235 | * ?> 236 | * ``` 237 | * 238 | * @param $text 239 | * @param null $selector 240 | * Conditional Assertion: Test won't be stopped on fail 241 | * @see \Codeception\Lib\InnerBrowser::dontSee() 242 | */ 243 | public function cantSee($text, $selector = null) { 244 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); 245 | } 246 | /** 247 | * [!] Method is generated. Documentation taken from corresponding module. 248 | * 249 | * Check if current page doesn't contain the text specified. 250 | * Specify the css selector to match only specific region. 251 | * 252 | * Examples: 253 | * 254 | * ```php 255 | * dontSee('Login'); // I can suppose user is already logged in 257 | * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page 258 | * $I->dontSee('Sign Up','//body/h1'); // with XPath 259 | * ?> 260 | * ``` 261 | * 262 | * @param $text 263 | * @param null $selector 264 | * @see \Codeception\Lib\InnerBrowser::dontSee() 265 | */ 266 | public function dontSee($text, $selector = null) { 267 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); 268 | } 269 | 270 | 271 | /** 272 | * [!] Method is generated. Documentation taken from corresponding module. 273 | * 274 | * Checks if there is a link with text specified. 275 | * Specify url to match link with exact this url. 276 | * 277 | * Examples: 278 | * 279 | * ``` php 280 | * seeLink('Logout'); // matches Logout 282 | * $I->seeLink('Logout','/logout'); // matches Logout 283 | * ?> 284 | * ``` 285 | * 286 | * @param $text 287 | * @param null $url 288 | * Conditional Assertion: Test won't be stopped on fail 289 | * @see \Codeception\Lib\InnerBrowser::seeLink() 290 | */ 291 | public function canSeeLink($text, $url = null) { 292 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); 293 | } 294 | /** 295 | * [!] Method is generated. Documentation taken from corresponding module. 296 | * 297 | * Checks if there is a link with text specified. 298 | * Specify url to match link with exact this url. 299 | * 300 | * Examples: 301 | * 302 | * ``` php 303 | * seeLink('Logout'); // matches Logout 305 | * $I->seeLink('Logout','/logout'); // matches Logout 306 | * ?> 307 | * ``` 308 | * 309 | * @param $text 310 | * @param null $url 311 | * @see \Codeception\Lib\InnerBrowser::seeLink() 312 | */ 313 | public function seeLink($text, $url = null) { 314 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); 315 | } 316 | 317 | 318 | /** 319 | * [!] Method is generated. Documentation taken from corresponding module. 320 | * 321 | * Checks if page doesn't contain the link with text specified. 322 | * Specify url to narrow the results. 323 | * 324 | * Examples: 325 | * 326 | * ``` php 327 | * dontSeeLink('Logout'); // I suppose user is not logged in 329 | * ?> 330 | * ``` 331 | * 332 | * @param $text 333 | * @param null $url 334 | * Conditional Assertion: Test won't be stopped on fail 335 | * @see \Codeception\Lib\InnerBrowser::dontSeeLink() 336 | */ 337 | public function cantSeeLink($text, $url = null) { 338 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); 339 | } 340 | /** 341 | * [!] Method is generated. Documentation taken from corresponding module. 342 | * 343 | * Checks if page doesn't contain the link with text specified. 344 | * Specify url to narrow the results. 345 | * 346 | * Examples: 347 | * 348 | * ``` php 349 | * dontSeeLink('Logout'); // I suppose user is not logged in 351 | * ?> 352 | * ``` 353 | * 354 | * @param $text 355 | * @param null $url 356 | * @see \Codeception\Lib\InnerBrowser::dontSeeLink() 357 | */ 358 | public function dontSeeLink($text, $url = null) { 359 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); 360 | } 361 | 362 | 363 | /** 364 | * [!] Method is generated. Documentation taken from corresponding module. 365 | * 366 | * Checks that current uri contains a value 367 | * 368 | * ``` php 369 | * seeInCurrentUrl('home'); 372 | * // to match: /users/1 373 | * $I->seeInCurrentUrl('/users/'); 374 | * ?> 375 | * ``` 376 | * 377 | * @param $uri 378 | * Conditional Assertion: Test won't be stopped on fail 379 | * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() 380 | */ 381 | public function canSeeInCurrentUrl($uri) { 382 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); 383 | } 384 | /** 385 | * [!] Method is generated. Documentation taken from corresponding module. 386 | * 387 | * Checks that current uri contains a value 388 | * 389 | * ``` php 390 | * seeInCurrentUrl('home'); 393 | * // to match: /users/1 394 | * $I->seeInCurrentUrl('/users/'); 395 | * ?> 396 | * ``` 397 | * 398 | * @param $uri 399 | * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() 400 | */ 401 | public function seeInCurrentUrl($uri) { 402 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); 403 | } 404 | 405 | 406 | /** 407 | * [!] Method is generated. Documentation taken from corresponding module. 408 | * 409 | * Checks that current uri does not contain a value 410 | * 411 | * ``` php 412 | * dontSeeInCurrentUrl('/users/'); 414 | * ?> 415 | * ``` 416 | * 417 | * @param $uri 418 | * Conditional Assertion: Test won't be stopped on fail 419 | * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() 420 | */ 421 | public function cantSeeInCurrentUrl($uri) { 422 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); 423 | } 424 | /** 425 | * [!] Method is generated. Documentation taken from corresponding module. 426 | * 427 | * Checks that current uri does not contain a value 428 | * 429 | * ``` php 430 | * dontSeeInCurrentUrl('/users/'); 432 | * ?> 433 | * ``` 434 | * 435 | * @param $uri 436 | * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() 437 | */ 438 | public function dontSeeInCurrentUrl($uri) { 439 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); 440 | } 441 | 442 | 443 | /** 444 | * [!] Method is generated. Documentation taken from corresponding module. 445 | * 446 | * Checks that current url is equal to value. 447 | * Unlike `seeInCurrentUrl` performs a strict check. 448 | * 449 | * ``` php 450 | * seeCurrentUrlEquals('/'); 453 | * ?> 454 | * ``` 455 | * 456 | * @param $uri 457 | * Conditional Assertion: Test won't be stopped on fail 458 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() 459 | */ 460 | public function canSeeCurrentUrlEquals($uri) { 461 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); 462 | } 463 | /** 464 | * [!] Method is generated. Documentation taken from corresponding module. 465 | * 466 | * Checks that current url is equal to value. 467 | * Unlike `seeInCurrentUrl` performs a strict check. 468 | * 469 | * ``` php 470 | * seeCurrentUrlEquals('/'); 473 | * ?> 474 | * ``` 475 | * 476 | * @param $uri 477 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() 478 | */ 479 | public function seeCurrentUrlEquals($uri) { 480 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); 481 | } 482 | 483 | 484 | /** 485 | * [!] Method is generated. Documentation taken from corresponding module. 486 | * 487 | * Checks that current url is not equal to value. 488 | * Unlike `dontSeeInCurrentUrl` performs a strict check. 489 | * 490 | * ``` php 491 | * dontSeeCurrentUrlEquals('/'); 494 | * ?> 495 | * ``` 496 | * 497 | * @param $uri 498 | * Conditional Assertion: Test won't be stopped on fail 499 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() 500 | */ 501 | public function cantSeeCurrentUrlEquals($uri) { 502 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); 503 | } 504 | /** 505 | * [!] Method is generated. Documentation taken from corresponding module. 506 | * 507 | * Checks that current url is not equal to value. 508 | * Unlike `dontSeeInCurrentUrl` performs a strict check. 509 | * 510 | * ``` php 511 | * dontSeeCurrentUrlEquals('/'); 514 | * ?> 515 | * ``` 516 | * 517 | * @param $uri 518 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() 519 | */ 520 | public function dontSeeCurrentUrlEquals($uri) { 521 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); 522 | } 523 | 524 | 525 | /** 526 | * [!] Method is generated. Documentation taken from corresponding module. 527 | * 528 | * Checks that current url is matches a RegEx value 529 | * 530 | * ``` php 531 | * seeCurrentUrlMatches('~$/users/(\d+)~'); 534 | * ?> 535 | * ``` 536 | * 537 | * @param $uri 538 | * Conditional Assertion: Test won't be stopped on fail 539 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() 540 | */ 541 | public function canSeeCurrentUrlMatches($uri) { 542 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); 543 | } 544 | /** 545 | * [!] Method is generated. Documentation taken from corresponding module. 546 | * 547 | * Checks that current url is matches a RegEx value 548 | * 549 | * ``` php 550 | * seeCurrentUrlMatches('~$/users/(\d+)~'); 553 | * ?> 554 | * ``` 555 | * 556 | * @param $uri 557 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() 558 | */ 559 | public function seeCurrentUrlMatches($uri) { 560 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); 561 | } 562 | 563 | 564 | /** 565 | * [!] Method is generated. Documentation taken from corresponding module. 566 | * 567 | * Checks that current url does not match a RegEx value 568 | * 569 | * ``` php 570 | * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); 573 | * ?> 574 | * ``` 575 | * 576 | * @param $uri 577 | * Conditional Assertion: Test won't be stopped on fail 578 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() 579 | */ 580 | public function cantSeeCurrentUrlMatches($uri) { 581 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); 582 | } 583 | /** 584 | * [!] Method is generated. Documentation taken from corresponding module. 585 | * 586 | * Checks that current url does not match a RegEx value 587 | * 588 | * ``` php 589 | * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); 592 | * ?> 593 | * ``` 594 | * 595 | * @param $uri 596 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() 597 | */ 598 | public function dontSeeCurrentUrlMatches($uri) { 599 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); 600 | } 601 | 602 | 603 | /** 604 | * [!] Method is generated. Documentation taken from corresponding module. 605 | * 606 | * Takes a parameters from current URI by RegEx. 607 | * If no url provided returns full URI. 608 | * 609 | * ``` php 610 | * grabFromCurrentUrl('~$/user/(\d+)/~'); 612 | * $uri = $I->grabFromCurrentUrl(); 613 | * ?> 614 | * ``` 615 | * 616 | * @param null $uri 617 | * 618 | * @internal param $url 619 | * @return mixed 620 | * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() 621 | */ 622 | public function grabFromCurrentUrl($uri = null) { 623 | return $this->scenario->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); 624 | } 625 | 626 | 627 | /** 628 | * [!] Method is generated. Documentation taken from corresponding module. 629 | * 630 | * Assert if the specified checkbox is checked. 631 | * Use css selector or xpath to match. 632 | * 633 | * Example: 634 | * 635 | * ``` php 636 | * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms 638 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. 639 | * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); 640 | * ?> 641 | * ``` 642 | * 643 | * @param $checkbox 644 | * Conditional Assertion: Test won't be stopped on fail 645 | * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() 646 | */ 647 | public function canSeeCheckboxIsChecked($checkbox) { 648 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); 649 | } 650 | /** 651 | * [!] Method is generated. Documentation taken from corresponding module. 652 | * 653 | * Assert if the specified checkbox is checked. 654 | * Use css selector or xpath to match. 655 | * 656 | * Example: 657 | * 658 | * ``` php 659 | * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms 661 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. 662 | * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); 663 | * ?> 664 | * ``` 665 | * 666 | * @param $checkbox 667 | * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() 668 | */ 669 | public function seeCheckboxIsChecked($checkbox) { 670 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); 671 | } 672 | 673 | 674 | /** 675 | * [!] Method is generated. Documentation taken from corresponding module. 676 | * 677 | * Assert if the specified checkbox is unchecked. 678 | * Use css selector or xpath to match. 679 | * 680 | * Example: 681 | * 682 | * ``` php 683 | * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms 685 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. 686 | * ?> 687 | * ``` 688 | * 689 | * @param $checkbox 690 | * Conditional Assertion: Test won't be stopped on fail 691 | * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() 692 | */ 693 | public function cantSeeCheckboxIsChecked($checkbox) { 694 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); 695 | } 696 | /** 697 | * [!] Method is generated. Documentation taken from corresponding module. 698 | * 699 | * Assert if the specified checkbox is unchecked. 700 | * Use css selector or xpath to match. 701 | * 702 | * Example: 703 | * 704 | * ``` php 705 | * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms 707 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. 708 | * ?> 709 | * ``` 710 | * 711 | * @param $checkbox 712 | * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() 713 | */ 714 | public function dontSeeCheckboxIsChecked($checkbox) { 715 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); 716 | } 717 | 718 | 719 | /** 720 | * [!] Method is generated. Documentation taken from corresponding module. 721 | * 722 | * Checks that an input field or textarea contains value. 723 | * Field is matched either by label or CSS or Xpath 724 | * 725 | * Example: 726 | * 727 | * ``` php 728 | * seeInField('Body','Type your comment here'); 730 | * $I->seeInField('form textarea[name=body]','Type your comment here'); 731 | * $I->seeInField('form input[type=hidden]','hidden_value'); 732 | * $I->seeInField('#searchform input','Search'); 733 | * $I->seeInField('//form/*[@name=search]','Search'); 734 | * $I->seeInField(['name' => 'search'], 'Search'); 735 | * ?> 736 | * ``` 737 | * 738 | * @param $field 739 | * @param $value 740 | * Conditional Assertion: Test won't be stopped on fail 741 | * @see \Codeception\Lib\InnerBrowser::seeInField() 742 | */ 743 | public function canSeeInField($field, $value) { 744 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); 745 | } 746 | /** 747 | * [!] Method is generated. Documentation taken from corresponding module. 748 | * 749 | * Checks that an input field or textarea contains value. 750 | * Field is matched either by label or CSS or Xpath 751 | * 752 | * Example: 753 | * 754 | * ``` php 755 | * seeInField('Body','Type your comment here'); 757 | * $I->seeInField('form textarea[name=body]','Type your comment here'); 758 | * $I->seeInField('form input[type=hidden]','hidden_value'); 759 | * $I->seeInField('#searchform input','Search'); 760 | * $I->seeInField('//form/*[@name=search]','Search'); 761 | * $I->seeInField(['name' => 'search'], 'Search'); 762 | * ?> 763 | * ``` 764 | * 765 | * @param $field 766 | * @param $value 767 | * @see \Codeception\Lib\InnerBrowser::seeInField() 768 | */ 769 | public function seeInField($field, $value) { 770 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); 771 | } 772 | 773 | 774 | /** 775 | * [!] Method is generated. Documentation taken from corresponding module. 776 | * 777 | * Checks that an input field or textarea doesn't contain value. 778 | * Field is matched either by label or CSS or Xpath 779 | * Example: 780 | * 781 | * ``` php 782 | * dontSeeInField('Body','Type your comment here'); 784 | * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); 785 | * $I->dontSeeInField('form input[type=hidden]','hidden_value'); 786 | * $I->dontSeeInField('#searchform input','Search'); 787 | * $I->dontSeeInField('//form/*[@name=search]','Search'); 788 | * $I->seeInField(['name' => 'search'], 'Search'); 789 | * ?> 790 | * ``` 791 | * 792 | * @param $field 793 | * @param $value 794 | * Conditional Assertion: Test won't be stopped on fail 795 | * @see \Codeception\Lib\InnerBrowser::dontSeeInField() 796 | */ 797 | public function cantSeeInField($field, $value) { 798 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); 799 | } 800 | /** 801 | * [!] Method is generated. Documentation taken from corresponding module. 802 | * 803 | * Checks that an input field or textarea doesn't contain value. 804 | * Field is matched either by label or CSS or Xpath 805 | * Example: 806 | * 807 | * ``` php 808 | * dontSeeInField('Body','Type your comment here'); 810 | * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); 811 | * $I->dontSeeInField('form input[type=hidden]','hidden_value'); 812 | * $I->dontSeeInField('#searchform input','Search'); 813 | * $I->dontSeeInField('//form/*[@name=search]','Search'); 814 | * $I->seeInField(['name' => 'search'], 'Search'); 815 | * ?> 816 | * ``` 817 | * 818 | * @param $field 819 | * @param $value 820 | * @see \Codeception\Lib\InnerBrowser::dontSeeInField() 821 | */ 822 | public function dontSeeInField($field, $value) { 823 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); 824 | } 825 | 826 | 827 | /** 828 | * [!] Method is generated. Documentation taken from corresponding module. 829 | * 830 | * Submits a form located on page. 831 | * Specify the form by it's css or xpath selector. 832 | * Fill the form fields values as array. 833 | * 834 | * Skipped fields will be filled by their values from page. 835 | * You don't need to click the 'Submit' button afterwards. 836 | * This command itself triggers the request to form's action. 837 | * 838 | * Examples: 839 | * 840 | * ``` php 841 | * submitForm('#login', array('login' => 'davert', 'password' => '123456')); 843 | * 844 | * ``` 845 | * 846 | * For sample Sign Up form: 847 | * 848 | * ``` html 849 | *
    850 | * Login:
    851 | * Password:
    852 | * Do you agree to out terms?
    853 | * Select pricing plan 854 | * 855 | *
    856 | * ``` 857 | * I can write this: 858 | * 859 | * ``` php 860 | * submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true))); 862 | * 863 | * ``` 864 | * Note, that pricing plan will be set to Paid, as it's selected on page. 865 | * 866 | * @param $selector 867 | * @param $params 868 | * @see \Codeception\Lib\InnerBrowser::submitForm() 869 | */ 870 | public function submitForm($selector, $params) { 871 | return $this->scenario->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); 872 | } 873 | 874 | 875 | /** 876 | * [!] Method is generated. Documentation taken from corresponding module. 877 | * 878 | * Fills a text field or textarea with value. 879 | * 880 | * Example: 881 | * 882 | * ``` php 883 | * fillField("//input[@type='text']", "Hello World!"); 885 | * $I->fillField(['name' => 'email'], 'jon@mail.com'); 886 | * ?> 887 | * ``` 888 | * 889 | * @param $field 890 | * @param $value 891 | * @see \Codeception\Lib\InnerBrowser::fillField() 892 | */ 893 | public function fillField($field, $value) { 894 | return $this->scenario->runStep(new \Codeception\Step\Action('fillField', func_get_args())); 895 | } 896 | 897 | 898 | /** 899 | * [!] Method is generated. Documentation taken from corresponding module. 900 | * 901 | * Selects an option in select tag or in radio button group. 902 | * 903 | * Example: 904 | * 905 | * ``` php 906 | * selectOption('form select[name=account]', 'Premium'); 908 | * $I->selectOption('form input[name=payment]', 'Monthly'); 909 | * $I->selectOption('//form/select[@name=account]', 'Monthly'); 910 | * ?> 911 | * ``` 912 | * 913 | * Can select multiple options if second argument is array: 914 | * 915 | * ``` php 916 | * selectOption('Which OS do you use?', array('Windows','Linux')); 918 | * ?> 919 | * ``` 920 | * 921 | * @param $select 922 | * @param $option 923 | * @see \Codeception\Lib\InnerBrowser::selectOption() 924 | */ 925 | public function selectOption($select, $option) { 926 | return $this->scenario->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); 927 | } 928 | 929 | 930 | /** 931 | * [!] Method is generated. Documentation taken from corresponding module. 932 | * 933 | * Ticks a checkbox. 934 | * For radio buttons use `selectOption` method. 935 | * 936 | * Example: 937 | * 938 | * ``` php 939 | * checkOption('#agree'); 941 | * ?> 942 | * ``` 943 | * 944 | * @param $option 945 | * @see \Codeception\Lib\InnerBrowser::checkOption() 946 | */ 947 | public function checkOption($option) { 948 | return $this->scenario->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); 949 | } 950 | 951 | 952 | /** 953 | * [!] Method is generated. Documentation taken from corresponding module. 954 | * 955 | * Unticks a checkbox. 956 | * 957 | * Example: 958 | * 959 | * ``` php 960 | * uncheckOption('#notify'); 962 | * ?> 963 | * ``` 964 | * 965 | * @param $option 966 | * @see \Codeception\Lib\InnerBrowser::uncheckOption() 967 | */ 968 | public function uncheckOption($option) { 969 | return $this->scenario->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); 970 | } 971 | 972 | 973 | /** 974 | * [!] Method is generated. Documentation taken from corresponding module. 975 | * 976 | * Attaches file from Codeception data directory to upload field. 977 | * 978 | * Example: 979 | * 980 | * ``` php 981 | * attachFile('input[@type="file"]', 'prices.xls'); 984 | * ?> 985 | * ``` 986 | * 987 | * @param $field 988 | * @param $filename 989 | * @see \Codeception\Lib\InnerBrowser::attachFile() 990 | */ 991 | public function attachFile($field, $filename) { 992 | return $this->scenario->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); 993 | } 994 | 995 | 996 | /** 997 | * [!] Method is generated. Documentation taken from corresponding module. 998 | * 999 | * If your page triggers an ajax request, you can perform it manually. 1000 | * This action sends a GET ajax request with specified params. 1001 | * 1002 | * See ->sendAjaxPostRequest for examples. 1003 | * 1004 | * @param $uri 1005 | * @param $params 1006 | * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest() 1007 | */ 1008 | public function sendAjaxGetRequest($uri, $params = null) { 1009 | return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args())); 1010 | } 1011 | 1012 | 1013 | /** 1014 | * [!] Method is generated. Documentation taken from corresponding module. 1015 | * 1016 | * If your page triggers an ajax request, you can perform it manually. 1017 | * This action sends a POST ajax request with specified params. 1018 | * Additional params can be passed as array. 1019 | * 1020 | * Example: 1021 | * 1022 | * Imagine that by clicking checkbox you trigger ajax request which updates user settings. 1023 | * We emulate that click by running this ajax request manually. 1024 | * 1025 | * ``` php 1026 | * sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST 1028 | * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET 1029 | * 1030 | * ``` 1031 | * 1032 | * @param $uri 1033 | * @param $params 1034 | * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() 1035 | */ 1036 | public function sendAjaxPostRequest($uri, $params = null) { 1037 | return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args())); 1038 | } 1039 | 1040 | 1041 | /** 1042 | * [!] Method is generated. Documentation taken from corresponding module. 1043 | * 1044 | * If your page triggers an ajax request, you can perform it manually. 1045 | * This action sends an ajax request with specified method and params. 1046 | * 1047 | * Example: 1048 | * 1049 | * You need to perform an ajax request specifying the HTTP method. 1050 | * 1051 | * ``` php 1052 | * sendAjaxRequest('PUT', /posts/7', array('title' => 'new title'); 1054 | * 1055 | * ``` 1056 | * 1057 | * @param $method 1058 | * @param $uri 1059 | * @param $params 1060 | * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest() 1061 | */ 1062 | public function sendAjaxRequest($method, $uri, $params = null) { 1063 | return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args())); 1064 | } 1065 | 1066 | 1067 | /** 1068 | * [!] Method is generated. Documentation taken from corresponding module. 1069 | * 1070 | * Finds and returns text contents of element. 1071 | * Element is searched by CSS selector, XPath or matcher by regex. 1072 | * 1073 | * Example: 1074 | * 1075 | * ``` php 1076 | * grabTextFrom('h1'); 1078 | * $heading = $I->grabTextFrom('descendant-or-self::h1'); 1079 | * $value = $I->grabTextFrom('~ 1081 | * ``` 1082 | * 1083 | * @param $cssOrXPathOrRegex 1084 | * 1085 | * @return mixed 1086 | * @see \Codeception\Lib\InnerBrowser::grabTextFrom() 1087 | */ 1088 | public function grabTextFrom($cssOrXPathOrRegex) { 1089 | return $this->scenario->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); 1090 | } 1091 | 1092 | 1093 | /** 1094 | * [!] Method is generated. Documentation taken from corresponding module. 1095 | * 1096 | * Grabs attribute value from an element. 1097 | * Fails if element is not found. 1098 | * 1099 | * ``` php 1100 | * grabAttributeFrom('#tooltip', 'title'); 1102 | * ?> 1103 | * ``` 1104 | * 1105 | * 1106 | * @param $cssOrXpath 1107 | * @param $attribute 1108 | * @internal param $element 1109 | * @return mixed 1110 | * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom() 1111 | */ 1112 | public function grabAttributeFrom($cssOrXpath, $attribute) { 1113 | return $this->scenario->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); 1114 | } 1115 | 1116 | 1117 | /** 1118 | * [!] Method is generated. Documentation taken from corresponding module. 1119 | * 1120 | * @param $field 1121 | * 1122 | * @return array|mixed|null|string 1123 | * @see \Codeception\Lib\InnerBrowser::grabValueFrom() 1124 | */ 1125 | public function grabValueFrom($field) { 1126 | return $this->scenario->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); 1127 | } 1128 | 1129 | 1130 | /** 1131 | * [!] Method is generated. Documentation taken from corresponding module. 1132 | * 1133 | * Sets a cookie. 1134 | * 1135 | * @param $cookie 1136 | * @param $value 1137 | * 1138 | * @return mixed 1139 | * @see \Codeception\Lib\InnerBrowser::setCookie() 1140 | */ 1141 | public function setCookie($name, $val) { 1142 | return $this->scenario->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); 1143 | } 1144 | 1145 | 1146 | /** 1147 | * [!] Method is generated. Documentation taken from corresponding module. 1148 | * 1149 | * Grabs a cookie value. 1150 | * 1151 | * @param $cookie 1152 | * 1153 | * @return mixed 1154 | * @see \Codeception\Lib\InnerBrowser::grabCookie() 1155 | */ 1156 | public function grabCookie($name) { 1157 | return $this->scenario->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); 1158 | } 1159 | 1160 | 1161 | /** 1162 | * [!] Method is generated. Documentation taken from corresponding module. 1163 | * 1164 | * Checks that cookie is set. 1165 | * 1166 | * @param $cookie 1167 | * 1168 | * @return mixed 1169 | * Conditional Assertion: Test won't be stopped on fail 1170 | * @see \Codeception\Lib\InnerBrowser::seeCookie() 1171 | */ 1172 | public function canSeeCookie($name) { 1173 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); 1174 | } 1175 | /** 1176 | * [!] Method is generated. Documentation taken from corresponding module. 1177 | * 1178 | * Checks that cookie is set. 1179 | * 1180 | * @param $cookie 1181 | * 1182 | * @return mixed 1183 | * @see \Codeception\Lib\InnerBrowser::seeCookie() 1184 | */ 1185 | public function seeCookie($name) { 1186 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); 1187 | } 1188 | 1189 | 1190 | /** 1191 | * [!] Method is generated. Documentation taken from corresponding module. 1192 | * 1193 | * Checks that cookie doesn't exist 1194 | * 1195 | * @param $cookie 1196 | * 1197 | * @return mixed 1198 | * Conditional Assertion: Test won't be stopped on fail 1199 | * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() 1200 | */ 1201 | public function cantSeeCookie($name) { 1202 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); 1203 | } 1204 | /** 1205 | * [!] Method is generated. Documentation taken from corresponding module. 1206 | * 1207 | * Checks that cookie doesn't exist 1208 | * 1209 | * @param $cookie 1210 | * 1211 | * @return mixed 1212 | * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() 1213 | */ 1214 | public function dontSeeCookie($name) { 1215 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); 1216 | } 1217 | 1218 | 1219 | /** 1220 | * [!] Method is generated. Documentation taken from corresponding module. 1221 | * 1222 | * Unsets cookie 1223 | * 1224 | * @param $cookie 1225 | * 1226 | * @return mixed 1227 | * @see \Codeception\Lib\InnerBrowser::resetCookie() 1228 | */ 1229 | public function resetCookie($name) { 1230 | return $this->scenario->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); 1231 | } 1232 | 1233 | 1234 | /** 1235 | * [!] Method is generated. Documentation taken from corresponding module. 1236 | * 1237 | * Checks if element exists on a page, matching it by CSS or XPath. 1238 | * You can also specify expected attributes of this element. 1239 | * 1240 | * ``` php 1241 | * seeElement('.error'); 1243 | * $I->seeElement('//form/input[1]'); 1244 | * $I->seeElement('input', ['name' => 'login']); 1245 | * $I->seeElement('input', ['value' => '123456']); 1246 | * 1247 | * // strict locator in first arg, attributes in second 1248 | * $I->seeElement(['css' => 'form input'], ['name' => 'login']); 1249 | * ?> 1250 | * ``` 1251 | * 1252 | * @param $selector 1253 | * @param array $attributes 1254 | * @return 1255 | * Conditional Assertion: Test won't be stopped on fail 1256 | * @see \Codeception\Lib\InnerBrowser::seeElement() 1257 | */ 1258 | public function canSeeElement($selector, $attributes = null) { 1259 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); 1260 | } 1261 | /** 1262 | * [!] Method is generated. Documentation taken from corresponding module. 1263 | * 1264 | * Checks if element exists on a page, matching it by CSS or XPath. 1265 | * You can also specify expected attributes of this element. 1266 | * 1267 | * ``` php 1268 | * seeElement('.error'); 1270 | * $I->seeElement('//form/input[1]'); 1271 | * $I->seeElement('input', ['name' => 'login']); 1272 | * $I->seeElement('input', ['value' => '123456']); 1273 | * 1274 | * // strict locator in first arg, attributes in second 1275 | * $I->seeElement(['css' => 'form input'], ['name' => 'login']); 1276 | * ?> 1277 | * ``` 1278 | * 1279 | * @param $selector 1280 | * @param array $attributes 1281 | * @return 1282 | * @see \Codeception\Lib\InnerBrowser::seeElement() 1283 | */ 1284 | public function seeElement($selector, $attributes = null) { 1285 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); 1286 | } 1287 | 1288 | 1289 | /** 1290 | * [!] Method is generated. Documentation taken from corresponding module. 1291 | * 1292 | * Checks if element does not exist (or is visible) on a page, matching it by CSS or XPath 1293 | * You can also specify expected attributes of this element. 1294 | * 1295 | * Example: 1296 | * 1297 | * ``` php 1298 | * dontSeeElement('.error'); 1300 | * $I->dontSeeElement('//form/input[1]'); 1301 | * $I->dontSeeElement('input', ['name' => 'login']); 1302 | * $I->dontSeeElement('input', ['value' => '123456']); 1303 | * ?> 1304 | * ``` 1305 | * 1306 | * @param $selector 1307 | * Conditional Assertion: Test won't be stopped on fail 1308 | * @see \Codeception\Lib\InnerBrowser::dontSeeElement() 1309 | */ 1310 | public function cantSeeElement($selector, $attributes = null) { 1311 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); 1312 | } 1313 | /** 1314 | * [!] Method is generated. Documentation taken from corresponding module. 1315 | * 1316 | * Checks if element does not exist (or is visible) on a page, matching it by CSS or XPath 1317 | * You can also specify expected attributes of this element. 1318 | * 1319 | * Example: 1320 | * 1321 | * ``` php 1322 | * dontSeeElement('.error'); 1324 | * $I->dontSeeElement('//form/input[1]'); 1325 | * $I->dontSeeElement('input', ['name' => 'login']); 1326 | * $I->dontSeeElement('input', ['value' => '123456']); 1327 | * ?> 1328 | * ``` 1329 | * 1330 | * @param $selector 1331 | * @see \Codeception\Lib\InnerBrowser::dontSeeElement() 1332 | */ 1333 | public function dontSeeElement($selector, $attributes = null) { 1334 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); 1335 | } 1336 | 1337 | 1338 | /** 1339 | * [!] Method is generated. Documentation taken from corresponding module. 1340 | * 1341 | * Checks if option is selected in select field. 1342 | * 1343 | * ``` php 1344 | * seeOptionIsSelected('#form input[name=payment]', 'Visa'); 1346 | * ?> 1347 | * ``` 1348 | * 1349 | * @param $selector 1350 | * @param $optionText 1351 | * 1352 | * @return mixed 1353 | * Conditional Assertion: Test won't be stopped on fail 1354 | * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() 1355 | */ 1356 | public function canSeeOptionIsSelected($select, $optionText) { 1357 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args())); 1358 | } 1359 | /** 1360 | * [!] Method is generated. Documentation taken from corresponding module. 1361 | * 1362 | * Checks if option is selected in select field. 1363 | * 1364 | * ``` php 1365 | * seeOptionIsSelected('#form input[name=payment]', 'Visa'); 1367 | * ?> 1368 | * ``` 1369 | * 1370 | * @param $selector 1371 | * @param $optionText 1372 | * 1373 | * @return mixed 1374 | * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() 1375 | */ 1376 | public function seeOptionIsSelected($select, $optionText) { 1377 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args())); 1378 | } 1379 | 1380 | 1381 | /** 1382 | * [!] Method is generated. Documentation taken from corresponding module. 1383 | * 1384 | * Checks if option is not selected in select field. 1385 | * 1386 | * ``` php 1387 | * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); 1389 | * ?> 1390 | * ``` 1391 | * 1392 | * @param $selector 1393 | * @param $optionText 1394 | * 1395 | * @return mixed 1396 | * Conditional Assertion: Test won't be stopped on fail 1397 | * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() 1398 | */ 1399 | public function cantSeeOptionIsSelected($select, $optionText) { 1400 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args())); 1401 | } 1402 | /** 1403 | * [!] Method is generated. Documentation taken from corresponding module. 1404 | * 1405 | * Checks if option is not selected in select field. 1406 | * 1407 | * ``` php 1408 | * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); 1410 | * ?> 1411 | * ``` 1412 | * 1413 | * @param $selector 1414 | * @param $optionText 1415 | * 1416 | * @return mixed 1417 | * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() 1418 | */ 1419 | public function dontSeeOptionIsSelected($select, $optionText) { 1420 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); 1421 | } 1422 | 1423 | 1424 | /** 1425 | * [!] Method is generated. Documentation taken from corresponding module. 1426 | * 1427 | * Asserts that current page has 404 response status code. 1428 | * Conditional Assertion: Test won't be stopped on fail 1429 | * @see \Codeception\Lib\InnerBrowser::seePageNotFound() 1430 | */ 1431 | public function canSeePageNotFound() { 1432 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args())); 1433 | } 1434 | /** 1435 | * [!] Method is generated. Documentation taken from corresponding module. 1436 | * 1437 | * Asserts that current page has 404 response status code. 1438 | * @see \Codeception\Lib\InnerBrowser::seePageNotFound() 1439 | */ 1440 | public function seePageNotFound() { 1441 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args())); 1442 | } 1443 | 1444 | 1445 | /** 1446 | * [!] Method is generated. Documentation taken from corresponding module. 1447 | * 1448 | * Checks that response code is equal to value provided. 1449 | * 1450 | * @param $code 1451 | * 1452 | * @return mixed 1453 | * Conditional Assertion: Test won't be stopped on fail 1454 | * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() 1455 | */ 1456 | public function canSeeResponseCodeIs($code) { 1457 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args())); 1458 | } 1459 | /** 1460 | * [!] Method is generated. Documentation taken from corresponding module. 1461 | * 1462 | * Checks that response code is equal to value provided. 1463 | * 1464 | * @param $code 1465 | * 1466 | * @return mixed 1467 | * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() 1468 | */ 1469 | public function seeResponseCodeIs($code) { 1470 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args())); 1471 | } 1472 | 1473 | 1474 | /** 1475 | * [!] Method is generated. Documentation taken from corresponding module. 1476 | * 1477 | * Checks that page title contains text. 1478 | * 1479 | * ``` php 1480 | * seeInTitle('Blog - Post #1'); 1482 | * ?> 1483 | * ``` 1484 | * 1485 | * @param $title 1486 | * 1487 | * @return mixed 1488 | * Conditional Assertion: Test won't be stopped on fail 1489 | * @see \Codeception\Lib\InnerBrowser::seeInTitle() 1490 | */ 1491 | public function canSeeInTitle($title) { 1492 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); 1493 | } 1494 | /** 1495 | * [!] Method is generated. Documentation taken from corresponding module. 1496 | * 1497 | * Checks that page title contains text. 1498 | * 1499 | * ``` php 1500 | * seeInTitle('Blog - Post #1'); 1502 | * ?> 1503 | * ``` 1504 | * 1505 | * @param $title 1506 | * 1507 | * @return mixed 1508 | * @see \Codeception\Lib\InnerBrowser::seeInTitle() 1509 | */ 1510 | public function seeInTitle($title) { 1511 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args())); 1512 | } 1513 | 1514 | 1515 | /** 1516 | * [!] Method is generated. Documentation taken from corresponding module. 1517 | * 1518 | * Checks that page title does not contain text. 1519 | * 1520 | * @param $title 1521 | * 1522 | * @return mixed 1523 | * Conditional Assertion: Test won't be stopped on fail 1524 | * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() 1525 | */ 1526 | public function cantSeeInTitle($title) { 1527 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args())); 1528 | } 1529 | /** 1530 | * [!] Method is generated. Documentation taken from corresponding module. 1531 | * 1532 | * Checks that page title does not contain text. 1533 | * 1534 | * @param $title 1535 | * 1536 | * @return mixed 1537 | * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() 1538 | */ 1539 | public function dontSeeInTitle($title) { 1540 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); 1541 | } 1542 | } 1543 | -------------------------------------------------------------------------------- /tests/acceptance/_bootstrap.php: -------------------------------------------------------------------------------- 1 | scenario->runStep(new \Codeception\Step\Condition('amInPath', func_get_args())); 38 | } 39 | 40 | 41 | /** 42 | * [!] Method is generated. Documentation taken from corresponding module. 43 | * 44 | * Opens a file and stores it's content. 45 | * 46 | * Usage: 47 | * 48 | * ``` php 49 | * openFile('composer.json'); 51 | * $I->seeInThisFile('codeception/codeception'); 52 | * ?> 53 | * ``` 54 | * 55 | * @param $filename 56 | * @see \Codeception\Module\Filesystem::openFile() 57 | */ 58 | public function openFile($filename) { 59 | return $this->scenario->runStep(new \Codeception\Step\Action('openFile', func_get_args())); 60 | } 61 | 62 | 63 | /** 64 | * [!] Method is generated. Documentation taken from corresponding module. 65 | * 66 | * Deletes a file 67 | * 68 | * ``` php 69 | * deleteFile('composer.lock'); 71 | * ?> 72 | * ``` 73 | * 74 | * @param $filename 75 | * @see \Codeception\Module\Filesystem::deleteFile() 76 | */ 77 | public function deleteFile($filename) { 78 | return $this->scenario->runStep(new \Codeception\Step\Action('deleteFile', func_get_args())); 79 | } 80 | 81 | 82 | /** 83 | * [!] Method is generated. Documentation taken from corresponding module. 84 | * 85 | * Deletes directory with all subdirectories 86 | * 87 | * ``` php 88 | * deleteDir('vendor'); 90 | * ?> 91 | * ``` 92 | * 93 | * @param $dirname 94 | * @see \Codeception\Module\Filesystem::deleteDir() 95 | */ 96 | public function deleteDir($dirname) { 97 | return $this->scenario->runStep(new \Codeception\Step\Action('deleteDir', func_get_args())); 98 | } 99 | 100 | 101 | /** 102 | * [!] Method is generated. Documentation taken from corresponding module. 103 | * 104 | * Copies directory with all contents 105 | * 106 | * ``` php 107 | * copyDir('vendor','old_vendor'); 109 | * ?> 110 | * ``` 111 | * 112 | * @param $src 113 | * @param $dst 114 | * @see \Codeception\Module\Filesystem::copyDir() 115 | */ 116 | public function copyDir($src, $dst) { 117 | return $this->scenario->runStep(new \Codeception\Step\Action('copyDir', func_get_args())); 118 | } 119 | 120 | 121 | /** 122 | * [!] Method is generated. Documentation taken from corresponding module. 123 | * 124 | * Checks If opened file has `text` in it. 125 | * 126 | * Usage: 127 | * 128 | * ``` php 129 | * openFile('composer.json'); 131 | * $I->seeInThisFile('codeception/codeception'); 132 | * ?> 133 | * ``` 134 | * 135 | * @param $text 136 | * Conditional Assertion: Test won't be stopped on fail 137 | * @see \Codeception\Module\Filesystem::seeInThisFile() 138 | */ 139 | public function canSeeInThisFile($text) { 140 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInThisFile', func_get_args())); 141 | } 142 | /** 143 | * [!] Method is generated. Documentation taken from corresponding module. 144 | * 145 | * Checks If opened file has `text` in it. 146 | * 147 | * Usage: 148 | * 149 | * ``` php 150 | * openFile('composer.json'); 152 | * $I->seeInThisFile('codeception/codeception'); 153 | * ?> 154 | * ``` 155 | * 156 | * @param $text 157 | * @see \Codeception\Module\Filesystem::seeInThisFile() 158 | */ 159 | public function seeInThisFile($text) { 160 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInThisFile', func_get_args())); 161 | } 162 | 163 | 164 | /** 165 | * [!] Method is generated. Documentation taken from corresponding module. 166 | * 167 | * Checks the strict matching of file contents. 168 | * Unlike `seeInThisFile` will fail if file has something more than expected lines. 169 | * Better to use with HEREDOC strings. 170 | * Matching is done after removing "\r" chars from file content. 171 | * 172 | * ``` php 173 | * openFile('process.pid'); 175 | * $I->seeFileContentsEqual('3192'); 176 | * ?> 177 | * ``` 178 | * 179 | * @param $text 180 | * Conditional Assertion: Test won't be stopped on fail 181 | * @see \Codeception\Module\Filesystem::seeFileContentsEqual() 182 | */ 183 | public function canSeeFileContentsEqual($text) { 184 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeFileContentsEqual', func_get_args())); 185 | } 186 | /** 187 | * [!] Method is generated. Documentation taken from corresponding module. 188 | * 189 | * Checks the strict matching of file contents. 190 | * Unlike `seeInThisFile` will fail if file has something more than expected lines. 191 | * Better to use with HEREDOC strings. 192 | * Matching is done after removing "\r" chars from file content. 193 | * 194 | * ``` php 195 | * openFile('process.pid'); 197 | * $I->seeFileContentsEqual('3192'); 198 | * ?> 199 | * ``` 200 | * 201 | * @param $text 202 | * @see \Codeception\Module\Filesystem::seeFileContentsEqual() 203 | */ 204 | public function seeFileContentsEqual($text) { 205 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeFileContentsEqual', func_get_args())); 206 | } 207 | 208 | 209 | /** 210 | * [!] Method is generated. Documentation taken from corresponding module. 211 | * 212 | * Checks If opened file doesn't contain `text` in it 213 | * 214 | * ``` php 215 | * openFile('composer.json'); 217 | * $I->dontSeeInThisFile('codeception/codeception'); 218 | * ?> 219 | * ``` 220 | * 221 | * @param $text 222 | * Conditional Assertion: Test won't be stopped on fail 223 | * @see \Codeception\Module\Filesystem::dontSeeInThisFile() 224 | */ 225 | public function cantSeeInThisFile($text) { 226 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInThisFile', func_get_args())); 227 | } 228 | /** 229 | * [!] Method is generated. Documentation taken from corresponding module. 230 | * 231 | * Checks If opened file doesn't contain `text` in it 232 | * 233 | * ``` php 234 | * openFile('composer.json'); 236 | * $I->dontSeeInThisFile('codeception/codeception'); 237 | * ?> 238 | * ``` 239 | * 240 | * @param $text 241 | * @see \Codeception\Module\Filesystem::dontSeeInThisFile() 242 | */ 243 | public function dontSeeInThisFile($text) { 244 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInThisFile', func_get_args())); 245 | } 246 | 247 | 248 | /** 249 | * [!] Method is generated. Documentation taken from corresponding module. 250 | * 251 | * Deletes a file 252 | * @see \Codeception\Module\Filesystem::deleteThisFile() 253 | */ 254 | public function deleteThisFile() { 255 | return $this->scenario->runStep(new \Codeception\Step\Action('deleteThisFile', func_get_args())); 256 | } 257 | 258 | 259 | /** 260 | * [!] Method is generated. Documentation taken from corresponding module. 261 | * 262 | * Checks if file exists in path. 263 | * Opens a file when it's exists 264 | * 265 | * ``` php 266 | * seeFileFound('UserModel.php','app/models'); 268 | * ?> 269 | * ``` 270 | * 271 | * @param $filename 272 | * @param string $path 273 | * Conditional Assertion: Test won't be stopped on fail 274 | * @see \Codeception\Module\Filesystem::seeFileFound() 275 | */ 276 | public function canSeeFileFound($filename, $path = null) { 277 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeFileFound', func_get_args())); 278 | } 279 | /** 280 | * [!] Method is generated. Documentation taken from corresponding module. 281 | * 282 | * Checks if file exists in path. 283 | * Opens a file when it's exists 284 | * 285 | * ``` php 286 | * seeFileFound('UserModel.php','app/models'); 288 | * ?> 289 | * ``` 290 | * 291 | * @param $filename 292 | * @param string $path 293 | * @see \Codeception\Module\Filesystem::seeFileFound() 294 | */ 295 | public function seeFileFound($filename, $path = null) { 296 | return $this->scenario->runStep(new \Codeception\Step\Assertion('seeFileFound', func_get_args())); 297 | } 298 | 299 | 300 | /** 301 | * [!] Method is generated. Documentation taken from corresponding module. 302 | * 303 | * Checks if file does not exists in path 304 | * 305 | * @param $filename 306 | * @param string $path 307 | * Conditional Assertion: Test won't be stopped on fail 308 | * @see \Codeception\Module\Filesystem::dontSeeFileFound() 309 | */ 310 | public function cantSeeFileFound($filename, $path = null) { 311 | return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeFileFound', func_get_args())); 312 | } 313 | /** 314 | * [!] Method is generated. Documentation taken from corresponding module. 315 | * 316 | * Checks if file does not exists in path 317 | * 318 | * @param $filename 319 | * @param string $path 320 | * @see \Codeception\Module\Filesystem::dontSeeFileFound() 321 | */ 322 | public function dontSeeFileFound($filename, $path = null) { 323 | return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeFileFound', func_get_args())); 324 | } 325 | 326 | 327 | /** 328 | * [!] Method is generated. Documentation taken from corresponding module. 329 | * 330 | * Erases directory contents 331 | * 332 | * ``` php 333 | * cleanDir('logs'); 335 | * ?> 336 | * ``` 337 | * 338 | * @param $dirname 339 | * @see \Codeception\Module\Filesystem::cleanDir() 340 | */ 341 | public function cleanDir($dirname) { 342 | return $this->scenario->runStep(new \Codeception\Step\Action('cleanDir', func_get_args())); 343 | } 344 | 345 | 346 | /** 347 | * [!] Method is generated. Documentation taken from corresponding module. 348 | * 349 | * Saves contents to file 350 | * 351 | * @param $filename 352 | * @param $contents 353 | * @see \Codeception\Module\Filesystem::writeToFile() 354 | */ 355 | public function writeToFile($filename, $contents) { 356 | return $this->scenario->runStep(new \Codeception\Step\Action('writeToFile', func_get_args())); 357 | } 358 | } 359 | -------------------------------------------------------------------------------- /tests/functional/_bootstrap.php: -------------------------------------------------------------------------------- 1 | scenario->runStep(new \Codeception\Step\Action('assertEquals', func_get_args())); 41 | } 42 | 43 | 44 | /** 45 | * [!] Method is generated. Documentation taken from corresponding module. 46 | * 47 | * Checks that two variables are not equal 48 | * 49 | * @param $expected 50 | * @param $actual 51 | * @param string $message 52 | * @see \Codeception\Module\Asserts::assertNotEquals() 53 | */ 54 | public function assertNotEquals($expected, $actual, $message = null) { 55 | return $this->scenario->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args())); 56 | } 57 | 58 | 59 | /** 60 | * [!] Method is generated. Documentation taken from corresponding module. 61 | * 62 | * Checks that expected is greater than actual 63 | * 64 | * @param $expected 65 | * @param $actual 66 | * @param string $message 67 | * @see \Codeception\Module\Asserts::assertGreaterThan() 68 | */ 69 | public function assertGreaterThan($expected, $actual, $message = null) { 70 | return $this->scenario->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args())); 71 | } 72 | 73 | 74 | /** 75 | * [!] Method is generated. Documentation taken from corresponding module. 76 | * 77 | * @deprecated 78 | * @see \Codeception\Module\Asserts::assertGreaterThen() 79 | */ 80 | public function assertGreaterThen($expected, $actual, $message = null) { 81 | return $this->scenario->runStep(new \Codeception\Step\Action('assertGreaterThen', func_get_args())); 82 | } 83 | 84 | 85 | /** 86 | * [!] Method is generated. Documentation taken from corresponding module. 87 | * 88 | * Checks that expected is greater or equal than actual 89 | * 90 | * @param $expected 91 | * @param $actual 92 | * @param string $message 93 | * @see \Codeception\Module\Asserts::assertGreaterThanOrEqual() 94 | */ 95 | public function assertGreaterThanOrEqual($expected, $actual, $message = null) { 96 | return $this->scenario->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args())); 97 | } 98 | 99 | 100 | /** 101 | * [!] Method is generated. Documentation taken from corresponding module. 102 | * 103 | * @deprecated 104 | * @see \Codeception\Module\Asserts::assertGreaterThenOrEqual() 105 | */ 106 | public function assertGreaterThenOrEqual($expected, $actual, $message = null) { 107 | return $this->scenario->runStep(new \Codeception\Step\Action('assertGreaterThenOrEqual', func_get_args())); 108 | } 109 | 110 | 111 | /** 112 | * [!] Method is generated. Documentation taken from corresponding module. 113 | * 114 | * Checks that haystack contains needle 115 | * 116 | * @param $needle 117 | * @param $haystack 118 | * @param string $message 119 | * @see \Codeception\Module\Asserts::assertContains() 120 | */ 121 | public function assertContains($needle, $haystack, $message = null) { 122 | return $this->scenario->runStep(new \Codeception\Step\Action('assertContains', func_get_args())); 123 | } 124 | 125 | 126 | /** 127 | * [!] Method is generated. Documentation taken from corresponding module. 128 | * 129 | * Checks that haystack doesn't contain needle. 130 | * 131 | * @param $needle 132 | * @param $haystack 133 | * @param string $message 134 | * @see \Codeception\Module\Asserts::assertNotContains() 135 | */ 136 | public function assertNotContains($needle, $haystack, $message = null) { 137 | return $this->scenario->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args())); 138 | } 139 | 140 | 141 | /** 142 | * [!] Method is generated. Documentation taken from corresponding module. 143 | * 144 | * Checks that variable is empty. 145 | * 146 | * @param $actual 147 | * @param string $message 148 | * @see \Codeception\Module\Asserts::assertEmpty() 149 | */ 150 | public function assertEmpty($actual, $message = null) { 151 | return $this->scenario->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args())); 152 | } 153 | 154 | 155 | /** 156 | * [!] Method is generated. Documentation taken from corresponding module. 157 | * 158 | * Checks that variable is not empty. 159 | * 160 | * @param $actual 161 | * @param string $message 162 | * @see \Codeception\Module\Asserts::assertNotEmpty() 163 | */ 164 | public function assertNotEmpty($actual, $message = null) { 165 | return $this->scenario->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args())); 166 | } 167 | 168 | 169 | /** 170 | * [!] Method is generated. Documentation taken from corresponding module. 171 | * 172 | * Checks that variable is NULL 173 | * 174 | * @param $actual 175 | * @param string $message 176 | * @see \Codeception\Module\Asserts::assertNull() 177 | */ 178 | public function assertNull($actual, $message = null) { 179 | return $this->scenario->runStep(new \Codeception\Step\Action('assertNull', func_get_args())); 180 | } 181 | 182 | 183 | /** 184 | * [!] Method is generated. Documentation taken from corresponding module. 185 | * 186 | * Checks that variable is not NULL 187 | * 188 | * @param $actual 189 | * @param string $message 190 | * @see \Codeception\Module\Asserts::assertNotNull() 191 | */ 192 | public function assertNotNull($actual, $message = null) { 193 | return $this->scenario->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args())); 194 | } 195 | 196 | 197 | /** 198 | * [!] Method is generated. Documentation taken from corresponding module. 199 | * 200 | * Checks that condition is positive. 201 | * 202 | * @param $condition 203 | * @param string $message 204 | * @see \Codeception\Module\Asserts::assertTrue() 205 | */ 206 | public function assertTrue($condition, $message = null) { 207 | return $this->scenario->runStep(new \Codeception\Step\Action('assertTrue', func_get_args())); 208 | } 209 | 210 | 211 | /** 212 | * [!] Method is generated. Documentation taken from corresponding module. 213 | * 214 | * Checks that condition is negative. 215 | * 216 | * @param $condition 217 | * @param string $message 218 | * @see \Codeception\Module\Asserts::assertFalse() 219 | */ 220 | public function assertFalse($condition, $message = null) { 221 | return $this->scenario->runStep(new \Codeception\Step\Action('assertFalse', func_get_args())); 222 | } 223 | 224 | 225 | /** 226 | * [!] Method is generated. Documentation taken from corresponding module. 227 | * 228 | * Fails the test with message. 229 | * 230 | * @param $message 231 | * @see \Codeception\Module\Asserts::fail() 232 | */ 233 | public function fail($message) { 234 | return $this->scenario->runStep(new \Codeception\Step\Action('fail', func_get_args())); 235 | } 236 | } 237 | -------------------------------------------------------------------------------- /tests/unit/_bootstrap.php: -------------------------------------------------------------------------------- 1 |