Commit de83e4dd by Paul Klimov

Merge branch 'master' of github.com:yiisoft/yii2 into authclient

parents fc0d3bfe b59b77cd
User-agent: *
Disallow:
\ No newline at end of file
......@@ -8,6 +8,7 @@ settings:
suite_class: \PHPUnit_Framework_TestSuite
memory_limit: 1024M
log: true
colors: true
modules:
config:
Db:
......
......@@ -10,7 +10,7 @@ namespace app\commands;
use yii\console\Controller;
/**
* This command echoes what the first argument that you have entered.
* This command echoes the first argument that you have entered.
*
* This command is provided as an example for you to learn how to create console commands.
*
......
......@@ -16,10 +16,11 @@
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-swiftmailer": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*"
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-swiftmailer": "*"
},
"scripts": {
"post-create-project-cmd": [
......
<?php
// configuration adjustments for codeception acceptance tests. Will be merged with web.php config.
return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2basic_acceptance',
],
],
];
<?php
// configuration adjustments for codeception functional tests. Will be merged with web.php config.
return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2basic_functional',
],
],
];
<?php
// configuration adjustments for codeception unit tests. Will be merged with web.php config.
return [
'components' => [
'fixture' => [
'class' => 'yii\test\DbFixtureManager',
'basePath' => '@tests/unit/fixtures',
],
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2basic_unit',
],
],
];
<?php
$config = require(__DIR__ . '/web.php');
// ... customize $config for the "test" environment here...
return $config;
<?php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
......@@ -26,14 +28,31 @@ $config = [
],
],
],
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2basic',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
],
'params' => $params,
];
if (YII_ENV_DEV) {
if (YII_ENV_DEV)
{
// configuration adjustments for 'dev' environment
$config['preload'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['modules']['gii'] = 'yii\gii\Module';
}
if (YII_ENV_TEST)
{
// configuration adjustments for 'test' environment.
// configuration for codeception test environments can be found in codeception folder.
// if needed, customize $config here.
}
return $config;
# these files are auto generated by codeception build
/unit/CodeGuy.php
/functional/TestGuy.php
/acceptance/WebGuy.php
......@@ -3,18 +3,26 @@ These tests are developed with [Codeception PHP Testing Framework](http://codece
To run the tests, follow these steps:
1. [Install Codeception](http://codeception.com/quickstart) if you do not have it yet.
2. Create test configuration files based on your environment:
- Copy `acceptance.suite.dist.yml` to `acceptance.suite.yml` and customize it;
- Copy `functional.suite.dist.yml` to `functional.suite.yml` and customize it;
- Copy `unit.suite.dist.yml` to `unit.suite.yml` and customize it.
3. Switch to the parent folder and run tests:
```
cd ..
php codecept.phar build // rebuild test scripts, only need to be run once
php codecept.phar run // run all available tests
```
1. Download Codeception([Quickstart step 1](http://codeception.com/quickstart)) and put the codeception.phar in the
application base directory (not in this `tests` directory!).
2. Adjust the test configuration files based on your environment:
- Configure the URL for [acceptance tests](http://codeception.com/docs/04-AcceptanceTests) in `acceptance.suite.yml`.
The URL should point to the `index-test-acceptance.php` file that is located under the `web` directory of the application.
- `functional.suite.yml` for [functional testing](http://codeception.com/docs/05-FunctionalTests) and
`unit.suite.yml` for [unit testing](http://codeception.com/docs/06-UnitTests) should already work out of the box
and should not need to be adjusted.
3. Go to the application base directory and build the test suites:
```
php codecept.phar build // rebuild test scripts, only need to be run once
```
4. Run the tests:
```
php codecept.phar run // run all available tests
// you can also run a test suite alone:
php codecept.phar run acceptance
php codecept.phar run functional
php codecept.phar run unit
```
Please refer to [Codeception tutorial](http://codeception.com/docs/01-Introduction) for
more details about writing acceptance, functional and unit tests.
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
Yii::setAlias('@tests', __DIR__);
<?php
namespace Codeception\Module;
// here you can define custom functions for CodeGuy
class CodeHelper extends \Codeception\Module
{
// here you can define custom methods for CodeGuy
}
<?php
namespace Codeception\Module;
// here you can define custom functions for TestGuy
class TestHelper extends \Codeception\Module
{
// here you can define custom methods for TestGuy
}
<?php
namespace Codeception\Module;
// here you can define custom functions for WebGuy
class WebHelper extends \Codeception\Module
{
// here you can define custom methods for WebGuy
}
<?php
namespace tests\_pages;
use yii\codeception\BasePage;
class AboutPage extends BasePage
{
public static $URL = '?r=site/about';
}
\ No newline at end of file
<?php
namespace tests\_pages;
use yii\codeception\BasePage;
class ContactPage extends BasePage
{
public static $URL = '?r=site/contact';
/**
* contact form name text field locator
* @var string
*/
public $name = 'input[name="ContactForm[name]"]';
/**
* contact form email text field locator
* @var string
*/
public $email = 'input[name="ContactForm[email]"]';
/**
* contact form subject text field locator
* @var string
*/
public $subject = 'input[name="ContactForm[subject]"]';
/**
* contact form body textarea locator
* @var string
*/
public $body = 'textarea[name="ContactForm[body]"]';
/**
* contact form verification code text field locator
* @var string
*/
public $verifyCode = 'input[name="ContactForm[verifyCode]"]';
/**
* contact form submit button
* @var string
*/
public $button = 'button[type=submit]';
/**
*
* @param array $contactData
*/
public function submit(array $contactData)
{
if (!empty($contactData))
{
$this->guy->fillField($this->name, $contactData['name']);
$this->guy->fillField($this->email, $contactData['email']);
$this->guy->fillField($this->subject, $contactData['subject']);
$this->guy->fillField($this->body, $contactData['body']);
$this->guy->fillField($this->verifyCode, $contactData['verifyCode']);
}
$this->guy->click($this->button);
}
}
<?php
namespace tests\_pages;
use yii\codeception\BasePage;
class LoginPage extends BasePage
{
public static $URL = '?r=site/login';
/**
* login form username text field locator
* @var string
*/
public $username = 'input[name="LoginForm[username]"]';
/**
* login form password text field locator
* @var string
*/
public $password = 'input[name="LoginForm[password]"]';
/**
* login form submit button locator
* @var string
*/
public $button = 'button[type=submit]';
/**
*
* @param string $username
* @param string $password
*/
public function login($username, $password)
{
$this->guy->fillField($this->username, $username);
$this->guy->fillField($this->password, $password);
$this->guy->click($this->button);
}
}
......@@ -11,8 +11,14 @@
class_name: WebGuy
modules:
enabled:
- PhpBrowser
- WebHelper
- PhpBrowser
# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
# - WebDriver
config:
PhpBrowser:
url: 'http://localhost/index-test.php'
url: 'http://localhost/basic-app/web/index-test-acceptance.php'
# WebDriver:
# url: 'http://localhost/basic-app/web/index-test-acceptance.php'
# browser: firefox
<?php
use tests\_pages\AboutPage;
$I = new WebGuy($scenario);
$I->wantTo('ensure that about works');
$I->amOnPage('?r=site/about');
$I->amOnPage(AboutPage::$URL);
$I->see('About', 'h1');
<?php
use tests\_pages\ContactPage;
$I = new WebGuy($scenario);
$I->wantTo('ensure that contact works');
$I->amOnPage('?r=site/contact');
$contactPage = ContactPage::of($I);
$I->amOnPage(ContactPage::$URL);
$I->see('Contact', 'h1');
$I->submitForm('#contact-form', []);
$I->amGoingTo('submit contact form with no data');
$contactPage->submit([]);
$I->expectTo('see validations errors');
$I->see('Contact', 'h1');
$I->see('Name cannot be blank');
$I->see('Email cannot be blank');
......@@ -12,25 +19,31 @@ $I->see('Subject cannot be blank');
$I->see('Body cannot be blank');
$I->see('The verification code is incorrect');
$I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester.email',
'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme',
$I->amGoingTo('submit contact form with not correct email');
$contactPage->submit([
'name' => 'tester',
'email' => 'tester.email',
'subject' => 'test subject',
'body' => 'test content',
'verifyCode' => 'testme',
]);
$I->expectTo('see that email adress is wrong');
$I->dontSee('Name cannot be blank', '.help-inline');
$I->see('Email is not a valid email address.');
$I->dontSee('Subject cannot be blank', '.help-inline');
$I->dontSee('Body cannot be blank', '.help-inline');
$I->dontSee('The verification code is incorrect', '.help-inline');
$I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester@example.com',
'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme',
$I->amGoingTo('submit contact form with correct data');
$contactPage->submit([
'name' => 'tester',
'email' => 'tester@example.com',
'subject' => 'test subject',
'body' => 'test content',
'verifyCode' => 'testme',
]);
if (method_exists($I, 'wait')) {
$I->wait(3); // only for selenium
}
$I->dontSeeElement('#contact-form');
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
<?php
$I = new WebGuy($scenario);
$I->wantTo('ensure that home page works');
$I->amOnPage('');
......
<?php
use tests\_pages\LoginPage;
$I = new WebGuy($scenario);
$I->wantTo('ensure that login works');
$I->amOnPage('?r=site/login');
$loginPage = LoginPage::of($I);
$I->amOnPage(LoginPage::$URL);
$I->see('Login', 'h1');
$I->submitForm('#login-form', []);
$I->dontSee('Logout (admin)');
$I->see('Username cannot be blank');
$I->see('Password cannot be blank');
$I->amGoingTo('try to login with empty credentials');
$loginPage->login('', '');
$I->expectTo('see validations errors');
$I->see('Username cannot be blank.');
$I->see('Password cannot be blank.');
$I->submitForm('#login-form', [
'LoginForm[username]' => 'admin',
'LoginForm[password]' => 'wrong',
]);
$I->dontSee('Logout (admin)');
$I->see('Incorrect username or password');
$I->amGoingTo('try to login with wrong credentials');
$loginPage->login('admin', 'wrong');
$I->expectTo('see validations errors');
$I->see('Incorrect username or password.');
$I->submitForm('#login-form', [
'LoginForm[username]' => 'admin',
'LoginForm[password]' => 'admin',
]);
$I->amGoingTo('try to login with correct credentials');
$loginPage->login('admin', 'admin');
if (method_exists($I, 'wait')) {
$I->wait(3); // only for selenium
}
$I->expectTo('see user info');
$I->see('Logout (admin)');
<?php
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
use \Codeception\Maybe;
use Codeception\Module\PhpBrowser;
use Codeception\Module\WebHelper;
/**
* Inherited methods
* @method void execute($callable)
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void offsetGet($offset)
* @method void offsetSet($offset, $value)
* @method void offsetExists($offset)
* @method void offsetUnset($offset)
*/
class WebGuy extends \Codeception\AbstractGuy
{
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Submits a form located on page.
* Specify the form by it's css or xpath selector.
* Fill the form fields values as array.
*
* Skipped fields will be filled by their values from page.
* You don't need to click the 'Submit' button afterwards.
* This command itself triggers the request to form's action.
*
* Examples:
*
* ``` php
* <?php
* $I->submitForm('#login', array('login' => 'davert', 'password' => '123456'));
*
* ```
*
* For sample Sign Up form:
*
* ``` html
* <form action="/sign_up">
* Login: <input type="text" name="user[login]" /><br/>
* Password: <input type="password" name="user[password]" /><br/>
* Do you agree to out terms? <input type="checkbox" name="user[agree]" /><br/>
* Select pricing plan <select name="plan"><option value="1">Free</option><option value="2" selected="selected">Paid</option></select>
* <input type="submit" value="Submit" />
* </form>
* ```
* I can write this:
*
* ``` php
* <?php
* $I->submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true)));
*
* ```
* Note, that pricing plan will be set to Paid, as it's selected on page.
*
* @param $selector
* @param $params
* @see Codeception\Module\PhpBrowser::submitForm()
* @return \Codeception\Maybe
*/
public function submitForm($selector, $params) {
$this->scenario->addStep(new \Codeception\Step\Action('submitForm', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* If your page triggers an ajax request, you can perform it manually.
* This action sends a POST ajax request with specified params.
* Additional params can be passed as array.
*
* Example:
*
* Imagine that by clicking checkbox you trigger ajax request which updates user settings.
* We emulate that click by running this ajax request manually.
*
* ``` php
* <?php
* $I->sendAjaxPostRequest('/updateSettings', array('notifications' => true); // POST
* $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true); // GET
*
* ```
*
* @param $uri
* @param $params
* @see Codeception\Module\PhpBrowser::sendAjaxPostRequest()
* @return \Codeception\Maybe
*/
public function sendAjaxPostRequest($uri, $params = null) {
$this->scenario->addStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* If your page triggers an ajax request, you can perform it manually.
* This action sends a GET ajax request with specified params.
*
* See ->sendAjaxPostRequest for examples.
*
* @param $uri
* @param $params
* @see Codeception\Module\PhpBrowser::sendAjaxGetRequest()
* @return \Codeception\Maybe
*/
public function sendAjaxGetRequest($uri, $params = null) {
$this->scenario->addStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Asserts that current page has 404 response status code.
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Module\PhpBrowser::seePageNotFound()
* @return \Codeception\Maybe
*/
public function canSeePageNotFound() {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Asserts that current page has 404 response status code.
* @see Codeception\Module\PhpBrowser::seePageNotFound()
* @return \Codeception\Maybe
*/
public function seePageNotFound() {
$this->scenario->addStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that response code is equal to value provided.
*
* @param $code
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Module\PhpBrowser::seeResponseCodeIs()
* @return \Codeception\Maybe
*/
public function canSeeResponseCodeIs($code) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that response code is equal to value provided.
*
* @param $code
* @return mixed
* @see Codeception\Module\PhpBrowser::seeResponseCodeIs()
* @return \Codeception\Maybe
*/
public function seeResponseCodeIs($code) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Adds HTTP authentication via username/password.
*
* @param $username
* @param $password
* @see Codeception\Module\PhpBrowser::amHttpAuthenticated()
* @return \Codeception\Maybe
*/
public function amHttpAuthenticated($username, $password) {
$this->scenario->addStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Low-level API method.
* If Codeception commands are not enough, use [Guzzle HTTP Client](http://guzzlephp.org/) methods directly
*
* Example:
*
* ``` php
* <?php
* // from the official Guzzle manual
* $I->amGoingTo('Sign all requests with OAuth');
* $I->executeInGuzzle(function (\Guzzle\Http\Client $client) {
* $client->addSubscriber(new Guzzle\Plugin\Oauth\OauthPlugin(array(
* 'consumer_key' => '***',
* 'consumer_secret' => '***',
* 'token' => '***',
* 'token_secret' => '***'
* )));
* });
* ?>
* ```
*
* Not recommended this command too be used on regular basis.
* If Codeception lacks important Guzzle Client methods implement then and submit patches.
*
* @param callable $function
* @see Codeception\Module\PhpBrowser::executeInGuzzle()
* @return \Codeception\Maybe
*/
public function executeInGuzzle($function) {
$this->scenario->addStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Assert if the specified checkbox is checked.
* Use css selector or xpath to match.
*
* Example:
*
* ``` php
* <?php
* $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
* $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
* ?>
* ```
*
* @param $checkbox
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Module\PhpBrowser::seeCheckboxIsChecked()
* @return \Codeception\Maybe
*/
public function canSeeCheckboxIsChecked($checkbox) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Assert if the specified checkbox is checked.
* Use css selector or xpath to match.
*
* Example:
*
* ``` php
* <?php
* $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
* $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
* ?>
* ```
*
* @param $checkbox
* @see Codeception\Module\PhpBrowser::seeCheckboxIsChecked()
* @return \Codeception\Maybe
*/
public function seeCheckboxIsChecked($checkbox) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Assert if the specified checkbox is unchecked.
* Use css selector or xpath to match.
*
* Example:
*
* ``` php
* <?php
* $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
* ?>
* ```
*
* @param $checkbox
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Module\PhpBrowser::dontSeeCheckboxIsChecked()
* @return \Codeception\Maybe
*/
public function cantSeeCheckboxIsChecked($checkbox) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Assert if the specified checkbox is unchecked.
* Use css selector or xpath to match.
*
* Example:
*
* ``` php
* <?php
* $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
* ?>
* ```
*
* @param $checkbox
* @see Codeception\Module\PhpBrowser::dontSeeCheckboxIsChecked()
* @return \Codeception\Maybe
*/
public function dontSeeCheckboxIsChecked($checkbox) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Opens the page.
*
* @param $page
* @see Codeception\Util\Mink::amOnPage()
* @return \Codeception\Maybe
*/
public function amOnPage($page) {
$this->scenario->addStep(new \Codeception\Step\Condition('amOnPage', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Sets 'url' configuration parameter to hosts subdomain.
* It does not open a page on subdomain. Use `amOnPage` for that
*
* ``` php
* <?php
* // If config is: 'http://mysite.com'
* // or config is: 'http://www.mysite.com'
* // or config is: 'http://company.mysite.com'
*
* $I->amOnSubdomain('user');
* $I->amOnPage('/');
* // moves to http://user.mysite.com/
* ?>
* ```
* @param $subdomain
* @return mixed
* @see Codeception\Util\Mink::amOnSubdomain()
* @return \Codeception\Maybe
*/
public function amOnSubdomain($subdomain) {
$this->scenario->addStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* @param string $text
* @param string $selector
*
* @return void
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::dontSee()
* @return \Codeception\Maybe
*/
public function cantSee($text, $selector = null) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* @param string $text
* @param string $selector
*
* @return void
* @see Codeception\Util\Mink::dontSee()
* @return \Codeception\Maybe
*/
public function dontSee($text, $selector = null) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSee', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Check if current page contains the text specified.
* Specify the css selector to match only specific region.
*
* Examples:
*
* ``` php
* <?php
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up','h1'); // I can suppose it's a signup page
* $I->see('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* @param $text
* @param null $selector
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::see()
* @return \Codeception\Maybe
*/
public function canSee($text, $selector = null) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Check if current page contains the text specified.
* Specify the css selector to match only specific region.
*
* Examples:
*
* ``` php
* <?php
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up','h1'); // I can suppose it's a signup page
* $I->see('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* @param $text
* @param null $selector
* @see Codeception\Util\Mink::see()
* @return \Codeception\Maybe
*/
public function see($text, $selector = null) {
$this->scenario->addStep(new \Codeception\Step\Assertion('see', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if there is a link with text specified.
* Specify url to match link with exact this url.
*
* Examples:
*
* ``` php
* <?php
* $I->seeLink('Logout'); // matches <a href="#">Logout</a>
* $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a>
* ?>
* ```
*
* @param $text
* @param null $url
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::seeLink()
* @return \Codeception\Maybe
*/
public function canSeeLink($text, $url = null) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if there is a link with text specified.
* Specify url to match link with exact this url.
*
* Examples:
*
* ``` php
* <?php
* $I->seeLink('Logout'); // matches <a href="#">Logout</a>
* $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a>
* ?>
* ```
*
* @param $text
* @param null $url
* @see Codeception\Util\Mink::seeLink()
* @return \Codeception\Maybe
*/
public function seeLink($text, $url = null) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeLink', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if page doesn't contain the link with text specified.
* Specify url to narrow the results.
*
* Examples:
*
* ``` php
* <?php
* $I->dontSeeLink('Logout'); // I suppose user is not logged in
* ?>
* ```
*
* @param $text
* @param null $url
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::dontSeeLink()
* @return \Codeception\Maybe
*/
public function cantSeeLink($text, $url = null) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if page doesn't contain the link with text specified.
* Specify url to narrow the results.
*
* Examples:
*
* ``` php
* <?php
* $I->dontSeeLink('Logout'); // I suppose user is not logged in
* ?>
* ```
*
* @param $text
* @param null $url
* @see Codeception\Util\Mink::dontSeeLink()
* @return \Codeception\Maybe
*/
public function dontSeeLink($text, $url = null) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Perform a click on link or button.
* Link or button are found by their names or CSS selector.
* Submits a form if button is a submit type.
*
* If link is an image it's found by alt attribute value of image.
* If button is image button is found by it's value
* If link or button can't be found by name they are searched by CSS selector.
*
* The second parameter is a context: CSS or XPath locator to narrow the search.
*
* Examples:
*
* ``` php
* <?php
* // simple link
* $I->click('Logout');
* // button of form
* $I->click('Submit');
* // CSS button
* $I->click('#form input[type=submit]');
* // XPath
* $I->click('//form/*[@type=submit]')
* // link in context
* $I->click('Logout', '#nav');
* ?>
* ```
* @param $link
* @param $context
* @see Codeception\Util\Mink::click()
* @return \Codeception\Maybe
*/
public function click($link, $context = null) {
$this->scenario->addStep(new \Codeception\Step\Action('click', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if element exists on a page, matching it by CSS or XPath
*
* ``` php
* <?php
* $I->seeElement('.error');
* $I->seeElement('//form/input[1]');
* ?>
* ```
* @param $selector
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::seeElement()
* @return \Codeception\Maybe
*/
public function canSeeElement($selector) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if element exists on a page, matching it by CSS or XPath
*
* ``` php
* <?php
* $I->seeElement('.error');
* $I->seeElement('//form/input[1]');
* ?>
* ```
* @param $selector
* @see Codeception\Util\Mink::seeElement()
* @return \Codeception\Maybe
*/
public function seeElement($selector) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeElement', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if element does not exist (or is visible) on a page, matching it by CSS or XPath
*
* Example:
*
* ``` php
* <?php
* $I->dontSeeElement('.error');
* $I->dontSeeElement('//form/input[1]');
* ?>
* ```
* @param $selector
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::dontSeeElement()
* @return \Codeception\Maybe
*/
public function cantSeeElement($selector) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if element does not exist (or is visible) on a page, matching it by CSS or XPath
*
* Example:
*
* ``` php
* <?php
* $I->dontSeeElement('.error');
* $I->dontSeeElement('//form/input[1]');
* ?>
* ```
* @param $selector
* @see Codeception\Util\Mink::dontSeeElement()
* @return \Codeception\Maybe
*/
public function dontSeeElement($selector) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Reloads current page
* @see Codeception\Util\Mink::reloadPage()
* @return \Codeception\Maybe
*/
public function reloadPage() {
$this->scenario->addStep(new \Codeception\Step\Action('reloadPage', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Moves back in history
* @see Codeception\Util\Mink::moveBack()
* @return \Codeception\Maybe
*/
public function moveBack() {
$this->scenario->addStep(new \Codeception\Step\Action('moveBack', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Moves forward in history
* @see Codeception\Util\Mink::moveForward()
* @return \Codeception\Maybe
*/
public function moveForward() {
$this->scenario->addStep(new \Codeception\Step\Action('moveForward', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Fills a text field or textarea with value.
*
* Example:
*
* ``` php
* <?php
* $I->fillField("//input[@type='text']", "Hello World!");
* ?>
* ```
*
* @param $field
* @param $value
* @see Codeception\Util\Mink::fillField()
* @return \Codeception\Maybe
*/
public function fillField($field, $value) {
$this->scenario->addStep(new \Codeception\Step\Action('fillField', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Selects an option in select tag or in radio button group.
*
* Example:
*
* ``` php
* <?php
* $I->selectOption('form select[name=account]', 'Premium');
* $I->selectOption('form input[name=payment]', 'Monthly');
* $I->selectOption('//form/select[@name=account]', 'Monthly');
* ?>
* ```
*
* Can select multiple options if second argument is array:
*
* ``` php
* <?php
* $I->selectOption('Which OS do you use?', array('Windows','Linux'));
* ?>
* ```
*
* @param $select
* @param $option
* @see Codeception\Util\Mink::selectOption()
* @return \Codeception\Maybe
*/
public function selectOption($select, $option) {
$this->scenario->addStep(new \Codeception\Step\Action('selectOption', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Ticks a checkbox.
* For radio buttons use `selectOption` method.
*
* Example:
*
* ``` php
* <?php
* $I->checkOption('#agree');
* ?>
* ```
*
* @param $option
* @see Codeception\Util\Mink::checkOption()
* @return \Codeception\Maybe
*/
public function checkOption($option) {
$this->scenario->addStep(new \Codeception\Step\Action('checkOption', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Unticks a checkbox.
*
* Example:
*
* ``` php
* <?php
* $I->uncheckOption('#notify');
* ?>
* ```
*
* @param $option
* @see Codeception\Util\Mink::uncheckOption()
* @return \Codeception\Maybe
*/
public function uncheckOption($option) {
$this->scenario->addStep(new \Codeception\Step\Action('uncheckOption', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current uri contains a value
*
* ``` php
* <?php
* // to match: /home/dashboard
* $I->seeInCurrentUrl('home');
* // to match: /users/1
* $I->seeInCurrentUrl('/users/');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::seeInCurrentUrl()
* @return \Codeception\Maybe
*/
public function canSeeInCurrentUrl($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current uri contains a value
*
* ``` php
* <?php
* // to match: /home/dashboard
* $I->seeInCurrentUrl('home');
* // to match: /users/1
* $I->seeInCurrentUrl('/users/');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Mink::seeInCurrentUrl()
* @return \Codeception\Maybe
*/
public function seeInCurrentUrl($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current uri does not contain a value
*
* ``` php
* <?php
* $I->dontSeeInCurrentUrl('/users/');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::dontSeeInCurrentUrl()
* @return \Codeception\Maybe
*/
public function cantSeeInCurrentUrl($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current uri does not contain a value
*
* ``` php
* <?php
* $I->dontSeeInCurrentUrl('/users/');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Mink::dontSeeInCurrentUrl()
* @return \Codeception\Maybe
*/
public function dontSeeInCurrentUrl($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is equal to value.
* Unlike `seeInCurrentUrl` performs a strict check.
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlEquals('/');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::seeCurrentUrlEquals()
* @return \Codeception\Maybe
*/
public function canSeeCurrentUrlEquals($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is equal to value.
* Unlike `seeInCurrentUrl` performs a strict check.
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlEquals('/');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Mink::seeCurrentUrlEquals()
* @return \Codeception\Maybe
*/
public function seeCurrentUrlEquals($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is not equal to value.
* Unlike `dontSeeInCurrentUrl` performs a strict check.
*
* ``` php
* <?php
* // current url is not root
* $I->dontSeeCurrentUrlEquals('/');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::dontSeeCurrentUrlEquals()
* @return \Codeception\Maybe
*/
public function cantSeeCurrentUrlEquals($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is not equal to value.
* Unlike `dontSeeInCurrentUrl` performs a strict check.
*
* ``` php
* <?php
* // current url is not root
* $I->dontSeeCurrentUrlEquals('/');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Mink::dontSeeCurrentUrlEquals()
* @return \Codeception\Maybe
*/
public function dontSeeCurrentUrlEquals($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is matches a RegEx value
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlMatches('~$/users/(\d+)~');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::seeCurrentUrlMatches()
* @return \Codeception\Maybe
*/
public function canSeeCurrentUrlMatches($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is matches a RegEx value
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlMatches('~$/users/(\d+)~');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Mink::seeCurrentUrlMatches()
* @return \Codeception\Maybe
*/
public function seeCurrentUrlMatches($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url does not match a RegEx value
*
* ``` php
* <?php
* // to match root url
* $I->dontSeeCurrentUrlMatches('~$/users/(\d+)~');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::dontSeeCurrentUrlMatches()
* @return \Codeception\Maybe
*/
public function cantSeeCurrentUrlMatches($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url does not match a RegEx value
*
* ``` php
* <?php
* // to match root url
* $I->dontSeeCurrentUrlMatches('~$/users/(\d+)~');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Mink::dontSeeCurrentUrlMatches()
* @return \Codeception\Maybe
*/
public function dontSeeCurrentUrlMatches($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that cookie is set.
*
* @param $cookie
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::seeCookie()
* @return \Codeception\Maybe
*/
public function canSeeCookie($cookie) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that cookie is set.
*
* @param $cookie
* @return mixed
* @see Codeception\Util\Mink::seeCookie()
* @return \Codeception\Maybe
*/
public function seeCookie($cookie) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeCookie', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that cookie doesn't exist
*
* @param $cookie
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::dontSeeCookie()
* @return \Codeception\Maybe
*/
public function cantSeeCookie($cookie) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that cookie doesn't exist
*
* @param $cookie
* @return mixed
* @see Codeception\Util\Mink::dontSeeCookie()
* @return \Codeception\Maybe
*/
public function dontSeeCookie($cookie) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Sets a cookie.
*
* @param $cookie
* @param $value
* @return mixed
* @see Codeception\Util\Mink::setCookie()
* @return \Codeception\Maybe
*/
public function setCookie($cookie, $value) {
$this->scenario->addStep(new \Codeception\Step\Action('setCookie', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Unsets cookie
*
* @param $cookie
* @return mixed
* @see Codeception\Util\Mink::resetCookie()
* @return \Codeception\Maybe
*/
public function resetCookie($cookie) {
$this->scenario->addStep(new \Codeception\Step\Action('resetCookie', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Grabs a cookie value.
*
* @param $cookie
* @return mixed
* @see Codeception\Util\Mink::grabCookie()
* @return \Codeception\Maybe
*/
public function grabCookie($cookie) {
$this->scenario->addStep(new \Codeception\Step\Action('grabCookie', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Takes a parameters from current URI by RegEx.
* If no url provided returns full URI.
*
* ``` php
* <?php
* $user_id = $I->grabFromCurrentUrl('~$/user/(\d+)/~');
* $uri = $I->grabFromCurrentUrl();
* ?>
* ```
*
* @param null $uri
* @internal param $url
* @return mixed
* @see Codeception\Util\Mink::grabFromCurrentUrl()
* @return \Codeception\Maybe
*/
public function grabFromCurrentUrl($uri = null) {
$this->scenario->addStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Attaches file from Codeception data directory to upload field.
*
* Example:
*
* ``` php
* <?php
* // file is stored in 'tests/_data/prices.xls'
* $I->attachFile('input[@type="file"]', 'prices.xls');
* ?>
* ```
*
* @param $field
* @param $filename
* @see Codeception\Util\Mink::attachFile()
* @return \Codeception\Maybe
*/
public function attachFile($field, $filename) {
$this->scenario->addStep(new \Codeception\Step\Action('attachFile', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if option is selected in select field.
*
* ``` php
* <?php
* $I->seeOptionIsSelected('#form input[name=payment]', 'Visa');
* ?>
* ```
*
* @param $selector
* @param $optionText
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::seeOptionIsSelected()
* @return \Codeception\Maybe
*/
public function canSeeOptionIsSelected($select, $text) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if option is selected in select field.
*
* ``` php
* <?php
* $I->seeOptionIsSelected('#form input[name=payment]', 'Visa');
* ?>
* ```
*
* @param $selector
* @param $optionText
* @return mixed
* @see Codeception\Util\Mink::seeOptionIsSelected()
* @return \Codeception\Maybe
*/
public function seeOptionIsSelected($select, $text) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if option is not selected in select field.
*
* ``` php
* <?php
* $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa');
* ?>
* ```
*
* @param $selector
* @param $optionText
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::dontSeeOptionIsSelected()
* @return \Codeception\Maybe
*/
public function cantSeeOptionIsSelected($select, $text) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if option is not selected in select field.
*
* ``` php
* <?php
* $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa');
* ?>
* ```
*
* @param $selector
* @param $optionText
* @return mixed
* @see Codeception\Util\Mink::dontSeeOptionIsSelected()
* @return \Codeception\Maybe
*/
public function dontSeeOptionIsSelected($select, $text) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that an input field or textarea contains value.
* Field is matched either by label or CSS or Xpath
*
* Example:
*
* ``` php
* <?php
* $I->seeInField('Body','Type your comment here');
* $I->seeInField('form textarea[name=body]','Type your comment here');
* $I->seeInField('form input[type=hidden]','hidden_value');
* $I->seeInField('#searchform input','Search');
* $I->seeInField('//form/*[@name=search]','Search');
* ?>
* ```
*
* @param $field
* @param $value
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::seeInField()
* @return \Codeception\Maybe
*/
public function canSeeInField($field, $value) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that an input field or textarea contains value.
* Field is matched either by label or CSS or Xpath
*
* Example:
*
* ``` php
* <?php
* $I->seeInField('Body','Type your comment here');
* $I->seeInField('form textarea[name=body]','Type your comment here');
* $I->seeInField('form input[type=hidden]','hidden_value');
* $I->seeInField('#searchform input','Search');
* $I->seeInField('//form/*[@name=search]','Search');
* ?>
* ```
*
* @param $field
* @param $value
* @see Codeception\Util\Mink::seeInField()
* @return \Codeception\Maybe
*/
public function seeInField($field, $value) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeInField', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that an input field or textarea doesn't contain value.
* Field is matched either by label or CSS or Xpath
* Example:
*
* ``` php
* <?php
* $I->dontSeeInField('Body','Type your comment here');
* $I->dontSeeInField('form textarea[name=body]','Type your comment here');
* $I->dontSeeInField('form input[type=hidden]','hidden_value');
* $I->dontSeeInField('#searchform input','Search');
* $I->dontSeeInField('//form/*[@name=search]','Search');
* ?>
* ```
*
* @param $field
* @param $value
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::dontSeeInField()
* @return \Codeception\Maybe
*/
public function cantSeeInField($field, $value) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that an input field or textarea doesn't contain value.
* Field is matched either by label or CSS or Xpath
* Example:
*
* ``` php
* <?php
* $I->dontSeeInField('Body','Type your comment here');
* $I->dontSeeInField('form textarea[name=body]','Type your comment here');
* $I->dontSeeInField('form input[type=hidden]','hidden_value');
* $I->dontSeeInField('#searchform input','Search');
* $I->dontSeeInField('//form/*[@name=search]','Search');
* ?>
* ```
*
* @param $field
* @param $value
* @see Codeception\Util\Mink::dontSeeInField()
* @return \Codeception\Maybe
*/
public function dontSeeInField($field, $value) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Finds and returns text contents of element.
* Element is searched by CSS selector, XPath or matcher by regex.
*
* Example:
*
* ``` php
* <?php
* $heading = $I->grabTextFrom('h1');
* $heading = $I->grabTextFrom('descendant-or-self::h1');
* $value = $I->grabTextFrom('~<input value=(.*?)]~sgi');
* ?>
* ```
*
* @param $cssOrXPathOrRegex
* @return mixed
* @see Codeception\Util\Mink::grabTextFrom()
* @return \Codeception\Maybe
*/
public function grabTextFrom($cssOrXPathOrRegex) {
$this->scenario->addStep(new \Codeception\Step\Action('grabTextFrom', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Finds and returns field and returns it's value.
* Searches by field name, then by CSS, then by XPath
*
* Example:
*
* ``` php
* <?php
* $name = $I->grabValueFrom('Name');
* $name = $I->grabValueFrom('input[name=username]');
* $name = $I->grabValueFrom('descendant-or-self::form/descendant::input[@name = 'username']');
* ?>
* ```
*
* @param $field
* @return mixed
* @see Codeception\Util\Mink::grabValueFrom()
* @return \Codeception\Maybe
*/
public function grabValueFrom($field) {
$this->scenario->addStep(new \Codeception\Step\Action('grabValueFrom', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that page title contains text.
*
* ``` php
* <?php
* $I->seeInTitle('Blog - Post #1');
* ?>
* ```
*
* @param $title
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::seeInTitle()
* @return \Codeception\Maybe
*/
public function canSeeInTitle($title) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that page title contains text.
*
* ``` php
* <?php
* $I->seeInTitle('Blog - Post #1');
* ?>
* ```
*
* @param $title
* @return mixed
* @see Codeception\Util\Mink::seeInTitle()
* @return \Codeception\Maybe
*/
public function seeInTitle($title) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that page title does not contain text.
*
* @param $title
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Mink::dontSeeInTitle()
* @return \Codeception\Maybe
*/
public function cantSeeInTitle($title) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that page title does not contain text.
*
* @param $title
* @return mixed
* @see Codeception\Util\Mink::dontSeeInTitle()
* @return \Codeception\Maybe
*/
public function dontSeeInTitle($title) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
}
<?php
// Here you can initialize variables that will for your tests
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../config/web.php'),
require(__DIR__ . '/../../config/codeception/acceptance.php')
);
$application = new yii\web\Application($config);
......@@ -5,11 +5,14 @@
# (tip: better to use with frameworks).
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
#basic/web/index.php
class_name: TestGuy
modules:
enabled: [Filesystem, TestHelper, Yii2]
enabled:
- Filesystem
- TestHelper
- Yii2
config:
Yii2:
entryScript: 'web/index-test.php'
entryScript: 'web/index-test-functional.php'
url: 'http://localhost/'
<?php
use tests\_pages\AboutPage;
$I = new TestGuy($scenario);
$I->wantTo('ensure that about works');
$I->amOnPage('?r=site/about');
$I->amOnPage(AboutPage::$URL);
$I->see('About', 'h1');
<?php
use tests\functional\_pages\ContactPage;
$I = new TestGuy($scenario);
$I->wantTo('ensure that contact works');
$I->amOnPage('?r=site/contact');
$contactPage = ContactPage::of($I);
$I->amOnPage(ContactPage::$URL);
$I->see('Contact', 'h1');
$I->submitForm('#contact-form', []);
$I->amGoingTo('submit contact form with no data');
$contactPage->submit([]);
$I->expectTo('see validations errors');
$I->see('Contact', 'h1');
$I->see('Name cannot be blank');
$I->see('Email cannot be blank');
......@@ -12,25 +19,28 @@ $I->see('Subject cannot be blank');
$I->see('Body cannot be blank');
$I->see('The verification code is incorrect');
$I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester.email',
'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme',
$I->amGoingTo('submit contact form with not correct email');
$contactPage->submit([
'name' => 'tester',
'email' => 'tester.email',
'subject' => 'test subject',
'body' => 'test content',
'verifyCode' => 'testme',
]);
$I->expectTo('see that email adress is wrong');
$I->dontSee('Name cannot be blank', '.help-inline');
$I->see('Email is not a valid email address.');
$I->dontSee('Subject cannot be blank', '.help-inline');
$I->dontSee('Body cannot be blank', '.help-inline');
$I->dontSee('The verification code is incorrect', '.help-inline');
$I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester@example.com',
'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme',
$I->amGoingTo('submit contact form with correct data');
$contactPage->submit([
'name' => 'tester',
'email' => 'tester@example.com',
'subject' => 'test subject',
'body' => 'test content',
'verifyCode' => 'testme',
]);
$I->dontSeeElement('#contact-form');
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
<?php
$I = new TestGuy($scenario);
$I->wantTo('ensure that home page works');
$I->amOnPage('');
......
<?php
use tests\functional\_pages\LoginPage;
$I = new TestGuy($scenario);
$I->wantTo('ensure that login works');
$I->amOnPage('?r=site/login');
$loginPage = LoginPage::of($I);
$I->amOnPage(LoginPage::$URL);
$I->see('Login', 'h1');
$I->submitForm('#login-form', []);
$I->dontSee('Logout (admin)');
$I->see('Username cannot be blank');
$I->see('Password cannot be blank');
$I->amGoingTo('try to login with empty credentials');
$loginPage->login('', '');
$I->expectTo('see validations errors');
$I->see('Username cannot be blank.');
$I->see('Password cannot be blank.');
$I->submitForm('#login-form', [
'LoginForm[username]' => 'admin',
'LoginForm[password]' => 'wrong',
]);
$I->dontSee('Logout (admin)');
$I->see('Incorrect username or password');
$I->amGoingTo('try to login with wrong credentials');
$loginPage->login('admin', 'wrong');
$I->expectTo('see validations errors');
$I->see('Incorrect username or password.');
$I->submitForm('#login-form', [
'LoginForm[username]' => 'admin',
'LoginForm[password]' => 'admin',
]);
$I->amGoingTo('try to login with correct credentials');
$loginPage->login('admin', 'admin');
$I->expectTo('see user info');
$I->see('Logout (admin)');
<?php
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
use \Codeception\Maybe;
use Codeception\Module\Filesystem;
use Codeception\Module\TestHelper;
use Codeception\Module\Yii2;
/**
* Inherited methods
* @method void execute($callable)
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void offsetGet($offset)
* @method void offsetSet($offset, $value)
* @method void offsetExists($offset)
* @method void offsetUnset($offset)
*/
class TestGuy extends \Codeception\AbstractGuy
{
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Enters a directory In local filesystem.
* Project root directory is used by default
*
* @param $path
* @see Codeception\Module\Filesystem::amInPath()
* @return \Codeception\Maybe
*/
public function amInPath($path) {
$this->scenario->addStep(new \Codeception\Step\Condition('amInPath', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Opens a file and stores it's content.
*
* Usage:
*
* ``` php
* <?php
* $I->openFile('composer.json');
* $I->seeInThisFile('codeception/codeception');
* ?>
* ```
*
* @param $filename
* @see Codeception\Module\Filesystem::openFile()
* @return \Codeception\Maybe
*/
public function openFile($filename) {
$this->scenario->addStep(new \Codeception\Step\Action('openFile', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Deletes a file
*
* ``` php
* <?php
* $I->deleteFile('composer.lock');
* ?>
* ```
*
* @param $filename
* @see Codeception\Module\Filesystem::deleteFile()
* @return \Codeception\Maybe
*/
public function deleteFile($filename) {
$this->scenario->addStep(new \Codeception\Step\Action('deleteFile', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Deletes directory with all subdirectories
*
* ``` php
* <?php
* $I->deleteDir('vendor');
* ?>
* ```
*
* @param $dirname
* @see Codeception\Module\Filesystem::deleteDir()
* @return \Codeception\Maybe
*/
public function deleteDir($dirname) {
$this->scenario->addStep(new \Codeception\Step\Action('deleteDir', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Copies directory with all contents
*
* ``` php
* <?php
* $I->copyDir('vendor','old_vendor');
* ?>
* ```
*
* @param $src
* @param $dst
* @see Codeception\Module\Filesystem::copyDir()
* @return \Codeception\Maybe
*/
public function copyDir($src, $dst) {
$this->scenario->addStep(new \Codeception\Step\Action('copyDir', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks If opened file has `text` in it.
*
* Usage:
*
* ``` php
* <?php
* $I->openFile('composer.json');
* $I->seeInThisFile('codeception/codeception');
* ?>
* ```
*
* @param $text
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Module\Filesystem::seeInThisFile()
* @return \Codeception\Maybe
*/
public function canSeeInThisFile($text) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeInThisFile', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks If opened file has `text` in it.
*
* Usage:
*
* ``` php
* <?php
* $I->openFile('composer.json');
* $I->seeInThisFile('codeception/codeception');
* ?>
* ```
*
* @param $text
* @see Codeception\Module\Filesystem::seeInThisFile()
* @return \Codeception\Maybe
*/
public function seeInThisFile($text) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeInThisFile', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks the strict matching of file contents.
* Unlike `seeInThisFile` will fail if file has something more then expected lines.
* Better to use with HEREDOC strings.
* Matching is done after removing "\r" chars from file content.
*
* ``` php
* <?php
* $I->openFile('process.pid');
* $I->seeFileContentsEqual('3192');
* ?>
* ```
*
* @param $text
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Module\Filesystem::seeFileContentsEqual()
* @return \Codeception\Maybe
*/
public function canSeeFileContentsEqual($text) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeFileContentsEqual', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks the strict matching of file contents.
* Unlike `seeInThisFile` will fail if file has something more then expected lines.
* Better to use with HEREDOC strings.
* Matching is done after removing "\r" chars from file content.
*
* ``` php
* <?php
* $I->openFile('process.pid');
* $I->seeFileContentsEqual('3192');
* ?>
* ```
*
* @param $text
* @see Codeception\Module\Filesystem::seeFileContentsEqual()
* @return \Codeception\Maybe
*/
public function seeFileContentsEqual($text) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeFileContentsEqual', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks If opened file doesn't contain `text` in it
*
* ``` php
* <?php
* $I->openFile('composer.json');
* $I->dontSeeInThisFile('codeception/codeception');
* ?>
* ```
*
* @param $text
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Module\Filesystem::dontSeeInThisFile()
* @return \Codeception\Maybe
*/
public function cantSeeInThisFile($text) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeInThisFile', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks If opened file doesn't contain `text` in it
*
* ``` php
* <?php
* $I->openFile('composer.json');
* $I->dontSeeInThisFile('codeception/codeception');
* ?>
* ```
*
* @param $text
* @see Codeception\Module\Filesystem::dontSeeInThisFile()
* @return \Codeception\Maybe
*/
public function dontSeeInThisFile($text) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeInThisFile', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Deletes a file
* @see Codeception\Module\Filesystem::deleteThisFile()
* @return \Codeception\Maybe
*/
public function deleteThisFile() {
$this->scenario->addStep(new \Codeception\Step\Action('deleteThisFile', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if file exists in path.
* Opens a file when it's exists
*
* ``` php
* <?php
* $I->seeFileFound('UserModel.php','app/models');
* ?>
* ```
*
* @param $filename
* @param string $path
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Module\Filesystem::seeFileFound()
* @return \Codeception\Maybe
*/
public function canSeeFileFound($filename, $path = null) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeFileFound', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if file exists in path.
* Opens a file when it's exists
*
* ``` php
* <?php
* $I->seeFileFound('UserModel.php','app/models');
* ?>
* ```
*
* @param $filename
* @param string $path
* @see Codeception\Module\Filesystem::seeFileFound()
* @return \Codeception\Maybe
*/
public function seeFileFound($filename, $path = null) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeFileFound', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Erases directory contents
*
* ``` php
* <?php
* $I->cleanDir('logs');
* ?>
* ```
*
* @param $dirname
* @see Codeception\Module\Filesystem::cleanDir()
* @return \Codeception\Maybe
*/
public function cleanDir($dirname) {
$this->scenario->addStep(new \Codeception\Step\Action('cleanDir', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Authenticates user for HTTP_AUTH
*
* @param $username
* @param $password
* @see Codeception\Util\Framework::amHttpAuthenticated()
* @return \Codeception\Maybe
*/
public function amHttpAuthenticated($username, $password) {
$this->scenario->addStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Opens the page.
* Requires relative uri as parameter
*
* Example:
*
* ``` php
* <?php
* // opens front page
* $I->amOnPage('/');
* // opens /register page
* $I->amOnPage('/register');
* ?>
* ```
*
* @param $page
* @see Codeception\Util\Framework::amOnPage()
* @return \Codeception\Maybe
*/
public function amOnPage($page) {
$this->scenario->addStep(new \Codeception\Step\Condition('amOnPage', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Perform a click on link or button.
* Link or button are found by their names or CSS selector.
* Submits a form if button is a submit type.
*
* If link is an image it's found by alt attribute value of image.
* If button is image button is found by it's value
* If link or button can't be found by name they are searched by CSS selector.
*
* The second parameter is a context: CSS or XPath locator to narrow the search.
*
* Examples:
*
* ``` php
* <?php
* // simple link
* $I->click('Logout');
* // button of form
* $I->click('Submit');
* // CSS button
* $I->click('#form input[type=submit]');
* // XPath
* $I->click('//form/*[@type=submit]')
* // link in context
* $I->click('Logout', '#nav');
* ?>
* ```
* @param $link
* @param $context
* @see Codeception\Util\Framework::click()
* @return \Codeception\Maybe
*/
public function click($link, $context = null) {
$this->scenario->addStep(new \Codeception\Step\Action('click', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Check if current page contains the text specified.
* Specify the css selector to match only specific region.
*
* Examples:
*
* ``` php
* <?php
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up','h1'); // I can suppose it's a signup page
* $I->see('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* @param $text
* @param null $selector
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::see()
* @return \Codeception\Maybe
*/
public function canSee($text, $selector = null) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Check if current page contains the text specified.
* Specify the css selector to match only specific region.
*
* Examples:
*
* ``` php
* <?php
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up','h1'); // I can suppose it's a signup page
* $I->see('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* @param $text
* @param null $selector
* @see Codeception\Util\Framework::see()
* @return \Codeception\Maybe
*/
public function see($text, $selector = null) {
$this->scenario->addStep(new \Codeception\Step\Assertion('see', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Check if current page doesn't contain the text specified.
* Specify the css selector to match only specific region.
*
* Examples:
*
* ```php
* <?php
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* @param $text
* @param null $selector
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::dontSee()
* @return \Codeception\Maybe
*/
public function cantSee($text, $selector = null) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Check if current page doesn't contain the text specified.
* Specify the css selector to match only specific region.
*
* Examples:
*
* ```php
* <?php
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* @param $text
* @param null $selector
* @see Codeception\Util\Framework::dontSee()
* @return \Codeception\Maybe
*/
public function dontSee($text, $selector = null) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSee', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if there is a link with text specified.
* Specify url to match link with exact this url.
*
* Examples:
*
* ``` php
* <?php
* $I->seeLink('Logout'); // matches <a href="#">Logout</a>
* $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a>
* ?>
* ```
*
* @param $text
* @param null $url
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::seeLink()
* @return \Codeception\Maybe
*/
public function canSeeLink($text, $url = null) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if there is a link with text specified.
* Specify url to match link with exact this url.
*
* Examples:
*
* ``` php
* <?php
* $I->seeLink('Logout'); // matches <a href="#">Logout</a>
* $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a>
* ?>
* ```
*
* @param $text
* @param null $url
* @see Codeception\Util\Framework::seeLink()
* @return \Codeception\Maybe
*/
public function seeLink($text, $url = null) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeLink', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if page doesn't contain the link with text specified.
* Specify url to narrow the results.
*
* Examples:
*
* ``` php
* <?php
* $I->dontSeeLink('Logout'); // I suppose user is not logged in
* ?>
* ```
*
* @param $text
* @param null $url
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::dontSeeLink()
* @return \Codeception\Maybe
*/
public function cantSeeLink($text, $url = null) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if page doesn't contain the link with text specified.
* Specify url to narrow the results.
*
* Examples:
*
* ``` php
* <?php
* $I->dontSeeLink('Logout'); // I suppose user is not logged in
* ?>
* ```
*
* @param $text
* @param null $url
* @see Codeception\Util\Framework::dontSeeLink()
* @return \Codeception\Maybe
*/
public function dontSeeLink($text, $url = null) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current uri contains a value
*
* ``` php
* <?php
* // to match: /home/dashboard
* $I->seeInCurrentUrl('home');
* // to match: /users/1
* $I->seeInCurrentUrl('/users/');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::seeInCurrentUrl()
* @return \Codeception\Maybe
*/
public function canSeeInCurrentUrl($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current uri contains a value
*
* ``` php
* <?php
* // to match: /home/dashboard
* $I->seeInCurrentUrl('home');
* // to match: /users/1
* $I->seeInCurrentUrl('/users/');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Framework::seeInCurrentUrl()
* @return \Codeception\Maybe
*/
public function seeInCurrentUrl($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current uri does not contain a value
*
* ``` php
* <?php
* $I->dontSeeInCurrentUrl('/users/');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::dontSeeInCurrentUrl()
* @return \Codeception\Maybe
*/
public function cantSeeInCurrentUrl($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current uri does not contain a value
*
* ``` php
* <?php
* $I->dontSeeInCurrentUrl('/users/');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Framework::dontSeeInCurrentUrl()
* @return \Codeception\Maybe
*/
public function dontSeeInCurrentUrl($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is equal to value.
* Unlike `seeInCurrentUrl` performs a strict check.
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlEquals('/');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::seeCurrentUrlEquals()
* @return \Codeception\Maybe
*/
public function canSeeCurrentUrlEquals($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is equal to value.
* Unlike `seeInCurrentUrl` performs a strict check.
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlEquals('/');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Framework::seeCurrentUrlEquals()
* @return \Codeception\Maybe
*/
public function seeCurrentUrlEquals($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is not equal to value.
* Unlike `dontSeeInCurrentUrl` performs a strict check.
*
* ``` php
* <?php
* // current url is not root
* $I->dontSeeCurrentUrlEquals('/');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::dontSeeCurrentUrlEquals()
* @return \Codeception\Maybe
*/
public function cantSeeCurrentUrlEquals($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is not equal to value.
* Unlike `dontSeeInCurrentUrl` performs a strict check.
*
* ``` php
* <?php
* // current url is not root
* $I->dontSeeCurrentUrlEquals('/');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Framework::dontSeeCurrentUrlEquals()
* @return \Codeception\Maybe
*/
public function dontSeeCurrentUrlEquals($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is matches a RegEx value
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlMatches('~$/users/(\d+)~');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::seeCurrentUrlMatches()
* @return \Codeception\Maybe
*/
public function canSeeCurrentUrlMatches($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url is matches a RegEx value
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlMatches('~$/users/(\d+)~');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Framework::seeCurrentUrlMatches()
* @return \Codeception\Maybe
*/
public function seeCurrentUrlMatches($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url does not match a RegEx value
*
* ``` php
* <?php
* // to match root url
* $I->dontSeeCurrentUrlMatches('~$/users/(\d+)~');
* ?>
* ```
*
* @param $uri
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::dontSeeCurrentUrlMatches()
* @return \Codeception\Maybe
*/
public function cantSeeCurrentUrlMatches($uri) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that current url does not match a RegEx value
*
* ``` php
* <?php
* // to match root url
* $I->dontSeeCurrentUrlMatches('~$/users/(\d+)~');
* ?>
* ```
*
* @param $uri
* @see Codeception\Util\Framework::dontSeeCurrentUrlMatches()
* @return \Codeception\Maybe
*/
public function dontSeeCurrentUrlMatches($uri) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Takes a parameters from current URI by RegEx.
* If no url provided returns full URI.
*
* ``` php
* <?php
* $user_id = $I->grabFromCurrentUrl('~$/user/(\d+)/~');
* $uri = $I->grabFromCurrentUrl();
* ?>
* ```
*
* @param null $uri
* @internal param $url
* @return mixed
* @see Codeception\Util\Framework::grabFromCurrentUrl()
* @return \Codeception\Maybe
*/
public function grabFromCurrentUrl($uri = null) {
$this->scenario->addStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Assert if the specified checkbox is checked.
* Use css selector or xpath to match.
*
* Example:
*
* ``` php
* <?php
* $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
* $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
* ?>
* ```
*
* @param $checkbox
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::seeCheckboxIsChecked()
* @return \Codeception\Maybe
*/
public function canSeeCheckboxIsChecked($checkbox) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Assert if the specified checkbox is checked.
* Use css selector or xpath to match.
*
* Example:
*
* ``` php
* <?php
* $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
* $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
* ?>
* ```
*
* @param $checkbox
* @see Codeception\Util\Framework::seeCheckboxIsChecked()
* @return \Codeception\Maybe
*/
public function seeCheckboxIsChecked($checkbox) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Assert if the specified checkbox is unchecked.
* Use css selector or xpath to match.
*
* Example:
*
* ``` php
* <?php
* $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
* ?>
* ```
*
* @param $checkbox
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::dontSeeCheckboxIsChecked()
* @return \Codeception\Maybe
*/
public function cantSeeCheckboxIsChecked($checkbox) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Assert if the specified checkbox is unchecked.
* Use css selector or xpath to match.
*
* Example:
*
* ``` php
* <?php
* $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
* ?>
* ```
*
* @param $checkbox
* @see Codeception\Util\Framework::dontSeeCheckboxIsChecked()
* @return \Codeception\Maybe
*/
public function dontSeeCheckboxIsChecked($checkbox) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that an input field or textarea contains value.
* Field is matched either by label or CSS or Xpath
*
* Example:
*
* ``` php
* <?php
* $I->seeInField('Body','Type your comment here');
* $I->seeInField('form textarea[name=body]','Type your comment here');
* $I->seeInField('form input[type=hidden]','hidden_value');
* $I->seeInField('#searchform input','Search');
* $I->seeInField('//form/*[@name=search]','Search');
* ?>
* ```
*
* @param $field
* @param $value
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::seeInField()
* @return \Codeception\Maybe
*/
public function canSeeInField($field, $value) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that an input field or textarea contains value.
* Field is matched either by label or CSS or Xpath
*
* Example:
*
* ``` php
* <?php
* $I->seeInField('Body','Type your comment here');
* $I->seeInField('form textarea[name=body]','Type your comment here');
* $I->seeInField('form input[type=hidden]','hidden_value');
* $I->seeInField('#searchform input','Search');
* $I->seeInField('//form/*[@name=search]','Search');
* ?>
* ```
*
* @param $field
* @param $value
* @see Codeception\Util\Framework::seeInField()
* @return \Codeception\Maybe
*/
public function seeInField($field, $value) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeInField', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that an input field or textarea doesn't contain value.
* Field is matched either by label or CSS or Xpath
* Example:
*
* ``` php
* <?php
* $I->dontSeeInField('Body','Type your comment here');
* $I->dontSeeInField('form textarea[name=body]','Type your comment here');
* $I->dontSeeInField('form input[type=hidden]','hidden_value');
* $I->dontSeeInField('#searchform input','Search');
* $I->dontSeeInField('//form/*[@name=search]','Search');
* ?>
* ```
*
* @param $field
* @param $value
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::dontSeeInField()
* @return \Codeception\Maybe
*/
public function cantSeeInField($field, $value) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that an input field or textarea doesn't contain value.
* Field is matched either by label or CSS or Xpath
* Example:
*
* ``` php
* <?php
* $I->dontSeeInField('Body','Type your comment here');
* $I->dontSeeInField('form textarea[name=body]','Type your comment here');
* $I->dontSeeInField('form input[type=hidden]','hidden_value');
* $I->dontSeeInField('#searchform input','Search');
* $I->dontSeeInField('//form/*[@name=search]','Search');
* ?>
* ```
*
* @param $field
* @param $value
* @see Codeception\Util\Framework::dontSeeInField()
* @return \Codeception\Maybe
*/
public function dontSeeInField($field, $value) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Submits a form located on page.
* Specify the form by it's css or xpath selector.
* Fill the form fields values as array.
*
* Skipped fields will be filled by their values from page.
* You don't need to click the 'Submit' button afterwards.
* This command itself triggers the request to form's action.
*
* Examples:
*
* ``` php
* <?php
* $I->submitForm('#login', array('login' => 'davert', 'password' => '123456'));
*
* ```
*
* For sample Sign Up form:
*
* ``` html
* <form action="/sign_up">
* Login: <input type="text" name="user[login]" /><br/>
* Password: <input type="password" name="user[password]" /><br/>
* Do you agree to out terms? <input type="checkbox" name="user[agree]" /><br/>
* Select pricing plan <select name="plan"><option value="1">Free</option><option value="2" selected="selected">Paid</option></select>
* <input type="submit" value="Submit" />
* </form>
* ```
* I can write this:
*
* ``` php
* <?php
* $I->submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true)));
*
* ```
* Note, that pricing plan will be set to Paid, as it's selected on page.
*
* @param $selector
* @param $params
* @see Codeception\Util\Framework::submitForm()
* @return \Codeception\Maybe
*/
public function submitForm($selector, $params) {
$this->scenario->addStep(new \Codeception\Step\Action('submitForm', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Fills a text field or textarea with value.
*
* Example:
*
* ``` php
* <?php
* $I->fillField("//input[@type='text']", "Hello World!");
* ?>
* ```
*
* @param $field
* @param $value
* @see Codeception\Util\Framework::fillField()
* @return \Codeception\Maybe
*/
public function fillField($field, $value) {
$this->scenario->addStep(new \Codeception\Step\Action('fillField', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Selects an option in select tag or in radio button group.
*
* Example:
*
* ``` php
* <?php
* $I->selectOption('form select[name=account]', 'Premium');
* $I->selectOption('form input[name=payment]', 'Monthly');
* $I->selectOption('//form/select[@name=account]', 'Monthly');
* ?>
* ```
*
* Can select multiple options if second argument is array:
*
* ``` php
* <?php
* $I->selectOption('Which OS do you use?', array('Windows','Linux'));
* ?>
* ```
*
* @param $select
* @param $option
* @see Codeception\Util\Framework::selectOption()
* @return \Codeception\Maybe
*/
public function selectOption($select, $option) {
$this->scenario->addStep(new \Codeception\Step\Action('selectOption', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Ticks a checkbox.
* For radio buttons use `selectOption` method.
*
* Example:
*
* ``` php
* <?php
* $I->checkOption('#agree');
* ?>
* ```
*
* @param $option
* @see Codeception\Util\Framework::checkOption()
* @return \Codeception\Maybe
*/
public function checkOption($option) {
$this->scenario->addStep(new \Codeception\Step\Action('checkOption', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Unticks a checkbox.
*
* Example:
*
* ``` php
* <?php
* $I->uncheckOption('#notify');
* ?>
* ```
*
* @param $option
* @see Codeception\Util\Framework::uncheckOption()
* @return \Codeception\Maybe
*/
public function uncheckOption($option) {
$this->scenario->addStep(new \Codeception\Step\Action('uncheckOption', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Attaches file from Codeception data directory to upload field.
*
* Example:
*
* ``` php
* <?php
* // file is stored in 'tests/_data/prices.xls'
* $I->attachFile('input[@type="file"]', 'prices.xls');
* ?>
* ```
*
* @param $field
* @param $filename
* @see Codeception\Util\Framework::attachFile()
* @return \Codeception\Maybe
*/
public function attachFile($field, $filename) {
$this->scenario->addStep(new \Codeception\Step\Action('attachFile', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* If your page triggers an ajax request, you can perform it manually.
* This action sends a GET ajax request with specified params.
*
* See ->sendAjaxPostRequest for examples.
*
* @param $uri
* @param $params
* @see Codeception\Util\Framework::sendAjaxGetRequest()
* @return \Codeception\Maybe
*/
public function sendAjaxGetRequest($uri, $params = null) {
$this->scenario->addStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* If your page triggers an ajax request, you can perform it manually.
* This action sends a POST ajax request with specified params.
* Additional params can be passed as array.
*
* Example:
*
* Imagine that by clicking checkbox you trigger ajax request which updates user settings.
* We emulate that click by running this ajax request manually.
*
* ``` php
* <?php
* $I->sendAjaxPostRequest('/updateSettings', array('notifications' => true); // POST
* $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true); // GET
*
* ```
*
* @param $uri
* @param $params
* @see Codeception\Util\Framework::sendAjaxPostRequest()
* @return \Codeception\Maybe
*/
public function sendAjaxPostRequest($uri, $params = null) {
$this->scenario->addStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Finds and returns text contents of element.
* Element is searched by CSS selector, XPath or matcher by regex.
*
* Example:
*
* ``` php
* <?php
* $heading = $I->grabTextFrom('h1');
* $heading = $I->grabTextFrom('descendant-or-self::h1');
* $value = $I->grabTextFrom('~<input value=(.*?)]~sgi');
* ?>
* ```
*
* @param $cssOrXPathOrRegex
* @return mixed
* @see Codeception\Util\Framework::grabTextFrom()
* @return \Codeception\Maybe
*/
public function grabTextFrom($cssOrXPathOrRegex) {
$this->scenario->addStep(new \Codeception\Step\Action('grabTextFrom', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Finds and returns field and returns it's value.
* Searches by field name, then by CSS, then by XPath
*
* Example:
*
* ``` php
* <?php
* $name = $I->grabValueFrom('Name');
* $name = $I->grabValueFrom('input[name=username]');
* $name = $I->grabValueFrom('descendant-or-self::form/descendant::input[@name = 'username']');
* ?>
* ```
*
* @param $field
* @return mixed
* @see Codeception\Util\Framework::grabValueFrom()
* @return \Codeception\Maybe
*/
public function grabValueFrom($field) {
$this->scenario->addStep(new \Codeception\Step\Action('grabValueFrom', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if element exists on a page, matching it by CSS or XPath
*
* ``` php
* <?php
* $I->seeElement('.error');
* $I->seeElement('//form/input[1]');
* ?>
* ```
* @param $selector
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::seeElement()
* @return \Codeception\Maybe
*/
public function canSeeElement($selector) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if element exists on a page, matching it by CSS or XPath
*
* ``` php
* <?php
* $I->seeElement('.error');
* $I->seeElement('//form/input[1]');
* ?>
* ```
* @param $selector
* @see Codeception\Util\Framework::seeElement()
* @return \Codeception\Maybe
*/
public function seeElement($selector) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeElement', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if element does not exist (or is visible) on a page, matching it by CSS or XPath
*
* Example:
*
* ``` php
* <?php
* $I->dontSeeElement('.error');
* $I->dontSeeElement('//form/input[1]');
* ?>
* ```
* @param $selector
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::dontSeeElement()
* @return \Codeception\Maybe
*/
public function cantSeeElement($selector) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if element does not exist (or is visible) on a page, matching it by CSS or XPath
*
* Example:
*
* ``` php
* <?php
* $I->dontSeeElement('.error');
* $I->dontSeeElement('//form/input[1]');
* ?>
* ```
* @param $selector
* @see Codeception\Util\Framework::dontSeeElement()
* @return \Codeception\Maybe
*/
public function dontSeeElement($selector) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if option is selected in select field.
*
* ``` php
* <?php
* $I->seeOptionIsSelected('#form input[name=payment]', 'Visa');
* ?>
* ```
*
* @param $selector
* @param $optionText
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::seeOptionIsSelected()
* @return \Codeception\Maybe
*/
public function canSeeOptionIsSelected($select, $optionText) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if option is selected in select field.
*
* ``` php
* <?php
* $I->seeOptionIsSelected('#form input[name=payment]', 'Visa');
* ?>
* ```
*
* @param $selector
* @param $optionText
* @return mixed
* @see Codeception\Util\Framework::seeOptionIsSelected()
* @return \Codeception\Maybe
*/
public function seeOptionIsSelected($select, $optionText) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if option is not selected in select field.
*
* ``` php
* <?php
* $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa');
* ?>
* ```
*
* @param $selector
* @param $optionText
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::dontSeeOptionIsSelected()
* @return \Codeception\Maybe
*/
public function cantSeeOptionIsSelected($select, $optionText) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks if option is not selected in select field.
*
* ``` php
* <?php
* $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa');
* ?>
* ```
*
* @param $selector
* @param $optionText
* @return mixed
* @see Codeception\Util\Framework::dontSeeOptionIsSelected()
* @return \Codeception\Maybe
*/
public function dontSeeOptionIsSelected($select, $optionText) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Asserts that current page has 404 response status code.
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::seePageNotFound()
* @return \Codeception\Maybe
*/
public function canSeePageNotFound() {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Asserts that current page has 404 response status code.
* @see Codeception\Util\Framework::seePageNotFound()
* @return \Codeception\Maybe
*/
public function seePageNotFound() {
$this->scenario->addStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that response code is equal to value provided.
*
* @param $code
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::seeResponseCodeIs()
* @return \Codeception\Maybe
*/
public function canSeeResponseCodeIs($code) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that response code is equal to value provided.
*
* @param $code
* @return mixed
* @see Codeception\Util\Framework::seeResponseCodeIs()
* @return \Codeception\Maybe
*/
public function seeResponseCodeIs($code) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that page title contains text.
*
* ``` php
* <?php
* $I->seeInTitle('Blog - Post #1');
* ?>
* ```
*
* @param $title
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::seeInTitle()
* @return \Codeception\Maybe
*/
public function canSeeInTitle($title) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that page title contains text.
*
* ``` php
* <?php
* $I->seeInTitle('Blog - Post #1');
* ?>
* ```
*
* @param $title
* @return mixed
* @see Codeception\Util\Framework::seeInTitle()
* @return \Codeception\Maybe
*/
public function seeInTitle($title) {
$this->scenario->addStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that page title does not contain text.
*
* @param $title
* @return mixed
* Conditional Assertion: Test won't be stopped on fail
* @see Codeception\Util\Framework::dontSeeInTitle()
* @return \Codeception\Maybe
*/
public function cantSeeInTitle($title) {
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
/**
* This method is generated.
* Documentation taken from corresponding module.
* ----------------------------------------------
*
* Checks that page title does not contain text.
*
* @param $title
* @return mixed
* @see Codeception\Util\Framework::dontSeeInTitle()
* @return \Codeception\Maybe
*/
public function dontSeeInTitle($title) {
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args()));
if ($this->scenario->running()) {
$result = $this->scenario->runStep();
return new Maybe($result);
}
return new Maybe();
}
}
<?php
// Here you can initialize variables that will for your tests
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../config/web.php'),
require(__DIR__ . '/../../config/codeception/functional.php')
);
$application = new yii\web\Application($config);
<?php
namespace tests\functional\_pages;
class ContactPage extends \tests\_pages\ContactPage
{
/**
* contact form name text field locator
* @var string
*/
public $name = 'ContactForm[name]';
/**
* contact form email text field locator
* @var string
*/
public $email = 'ContactForm[email]';
/**
* contact form subject text field locator
* @var string
*/
public $subject = 'ContactForm[subject]';
/**
* contact form body textarea locator
* @var string
*/
public $body = 'ContactForm[body]';
/**
* contact form verification code text field locator
* @var string
*/
public $verifyCode = 'ContactForm[verifyCode]';
/**
*
* @param array $contactData
*/
public function submit(array $contactData)
{
if (empty($contactData)) {
$this->guy->submitForm('#contact-form', []);
} else {
$this->guy->submitForm('#contact-form', [
$this->name => $contactData['name'],
$this->email => $contactData['email'],
$this->subject => $contactData['subject'],
$this->body => $contactData['body'],
$this->verifyCode => $contactData['verifyCode'],
]);
}
}
}
<?php
namespace tests\functional\_pages;
class LoginPage extends \tests\_pages\LoginPage
{
/**
* login form username text field locator
* @var string
*/
public $username = 'LoginForm[username]';
/**
* login form password text field locator
* @var string
*/
public $password = 'LoginForm[password]';
/**
*
* @param string $username
* @param string $password
*/
public function login($username, $password)
{
$this->guy->submitForm('#login-form', [
$this->username => $username,
$this->password => $password,
]);
}
}
......@@ -5,4 +5,5 @@
class_name: CodeGuy
modules:
enabled: [CodeHelper]
enabled:
- CodeHelper
<?php
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
use \Codeception\Maybe;
use Codeception\Module\CodeHelper;
/**
* Inherited methods
* @method void execute($callable)
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void offsetGet($offset)
* @method void offsetSet($offset, $value)
* @method void offsetExists($offset)
* @method void offsetUnset($offset)
*/
class CodeGuy extends \Codeception\AbstractGuy
{
}
<?php
// Here you can initialize variables that will for your tests
// add unit testing specific bootstrap code here
yii\codeception\TestCase::$applicationConfig = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../config/web.php'),
require(__DIR__ . '/../../config/codeception/unit.php')
);
\ No newline at end of file
<?php
namespace tests\unit\models;
use yii\codeception\TestCase;
class ContactFormTest extends TestCase
{
// TODO add test methods here
}
<?php
namespace tests\unit\models;
use yii\codeception\TestCase;
class LoginFormTest extends TestCase
{
// TODO add test methods here
}
\ No newline at end of file
<?php
namespace tests\unit\models;
use yii\codeception\TestCase;
use yii\test\DbTestTrait;
class UserTest extends TestCase
{
use DbTestTrait;
protected function setUp()
{
parent::setUp();
// uncomment the following to load fixtures for table tbl_user
//$this->loadFixtures(['tbl_user']);
}
// TODO add test methods here
}
<?php
// NOTE: Make sure this file is not accessable when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../config/web.php'),
require(__DIR__ . '/../config/codeception/acceptance.php')
);
$application = new yii\web\Application($config);
$application->run();
<?php
// this file is used as the entry script for codeception functional testing
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../config/web.php'),
require(__DIR__ . '/../config/codeception/functional.php')
);
$config['class'] = 'yii\web\Application';
return $config;
<?php
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.');
}
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
$config = require(__DIR__ . '/../config/web-test.php');
if (isset($this)) {
// run in functional tests
$config['class'] = 'yii\web\Application';
return $config;
} else {
// run in acceptance tests
$application = new yii\web\Application($config);
$application->run();
}
User-agent: *
Disallow:
\ No newline at end of file
......@@ -51,6 +51,7 @@
"minimum-stability": "dev",
"replace": {
"yiisoft/yii2-bootstrap": "self.version",
"yiisoft/yii2-codeception": "self.version",
"yiisoft/yii2-debug": "self.version",
"yiisoft/yii2-elasticsearch": "self.version",
"yiisoft/yii2-gii": "self.version",
......@@ -80,6 +81,7 @@
"autoload": {
"psr-0": {
"yii\\bootstrap\\": "extensions/",
"yii\\codeception\\": "extensions/",
"yii\\debug\\": "extensions/",
"yii\\elasticsearch\\": "extensions/",
"yii\\gii\\": "extensions/",
......
......@@ -8,7 +8,8 @@ as well as complete CRUD controllers.
Installing and configuring
--------------------------
Gii comes as an offical extension and the preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Gii comes as an offical extension and the preferred way to install this extension is through
[composer](http://getcomposer.org/download/).
Either run
......@@ -42,13 +43,44 @@ http://localhost/path/to/index.php?r=gii
> Note: if you are accessing gii from another IP than localhost, access will be denied by default.
You have to add allowed IPs to the configuration in this case:
```php
'gii' => [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // adjust this to your needs
],
```
>
```php
'gii' => [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // adjust this to your needs
],
```
### Basic application
In basic application template configuration structure is a bit different so Gii should be configured in
`config/web.php`:
```php
// ...
if (YII_ENV_DEV)
{
// configuration adjustments for 'dev' environment
$config['preload'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['modules']['gii'] = 'yii\gii\Module'; // <--- here
}
```
So in order to adjust IP address you need to do it like the following:
```php
if (YII_ENV_DEV)
{
// configuration adjustments for 'dev' environment
$config['preload'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'],
];
}
```
How to use it
-------------
......
......@@ -4,7 +4,8 @@ Yii Framework 2 bootstrap extension Change Log
2.0.0 beta under development
----------------------------
- no changes in this release.
- Enh #1474: Added option to make NavBar 100% width (cebe)
- Enh #1553: Only add navbar-default class to NavBar when no other class is specified (cebe)
2.0.0 alpha, December 1, 2013
-----------------------------
......
......@@ -50,8 +50,15 @@ class NavBar extends Widget
* @var array the HTML attributes of the brand link.
*/
public $brandOptions = [];
/**
* @var string text to show for screen readers for the button to toggle the navbar.
*/
public $screenReaderToggleText = 'Toggle navigation';
/**
* @var bool whether the navbar content should be included in a `container` div which adds left and right padding.
* Set this to false for a 100% width navbar.
*/
public $padded = true;
/**
* Initializes the widget.
......@@ -60,14 +67,19 @@ class NavBar extends Widget
{
parent::init();
$this->clientOptions = false;
Html::addCssClass($this->options, 'navbar navbar-default');
Html::addCssClass($this->options, 'navbar');
if ($this->options['class'] == 'navbar') {
Html::addCssClass($this->options, 'navbar-default');
}
Html::addCssClass($this->brandOptions, 'navbar-brand');
if (empty($this->options['role'])) {
$this->options['role'] = 'navigation';
}
echo Html::beginTag('nav', $this->options);
echo Html::beginTag('div', ['class' => 'container']);
if ($this->padded) {
echo Html::beginTag('div', ['class' => 'container']);
}
echo Html::beginTag('div', ['class' => 'navbar-header']);
echo $this->renderToggleButton();
......@@ -76,7 +88,7 @@ class NavBar extends Widget
}
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'collapse navbar-collapse navbar-ex1-collapse']);
echo Html::beginTag('div', ['class' => "collapse navbar-collapse navbar-{$this->options['id']}-collapse"]);
}
/**
......@@ -86,7 +98,9 @@ class NavBar extends Widget
{
echo Html::endTag('div');
echo Html::endTag('div');
if ($this->padded) {
echo Html::endTag('div');
}
echo Html::endTag('nav');
BootstrapPluginAsset::register($this->getView());
}
......@@ -102,7 +116,7 @@ class NavBar extends Widget
return Html::button("{$screenReader}\n{$bar}\n{$bar}\n{$bar}", [
'class' => 'navbar-toggle',
'data-toggle' => 'collapse',
'data-target' => '.navbar-ex1-collapse',
'data-target' => ".navbar-{$this->options['id']}-collapse",
]);
}
}
<?php
namespace yii\codeception;
/**
* Represents a web page to test
*
* Pages extend from this class and declare UI map for this page via
* static properties. CSS or XPath allowed.
*
* Here is an example:
*
* ```php
* public static $usernameField = '#username';
* public static $formSubmitButton = "#mainForm input[type=submit]";
* ```
*
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
abstract class BasePage
{
/**
* @var string include url of current page. This property has to be overwritten by subclasses
*/
public static $URL = '';
/**
* @var \Codeception\AbstractGuy
*/
protected $guy;
public function __construct($I)
{
$this->guy = $I;
}
/**
* Basic route example for your current URL
* You can append any additional parameter to URL
* and use it in tests like: EditPage::route('/123-post');
*/
public static function route($param)
{
return static::$URL.$param;
}
/**
* @param $I
* @return static
*/
public static function of($I)
{
return new static($I);
}
}
Yii Framework 2 Codeception extension Change Log
================================================
2.0.0 beta under development
----------------------------
- Initial release.
\ No newline at end of file
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Yii Software LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Codeception Extension for Yii 2
===============================
This extension provides a `Codeception` mail solution for Yii 2. It includes some classes that are useful
for unit-testing (```TestCase```) or for codeception page-objects (```BasePage```).
When using codeception page-objects they have some similar code, this code was extracted and put into the ```BasePage```
class to reduce code duplication. Simply extend your page object from this class, like it is done in ```yii2-basic``` and
```yii2-advanced``` boilerplates.
For unit testing there is a ```TestCase``` class which holds some common features like application creation before each test
and application destroy after each test. You can configure your application by this class. ```TestCase``` is extended from ```PHPUnit_Framework_TestCase``` so all
methods and assertions are available.
```php
SomeConsoleTest extends yii\codeception\TestCase
{
# by default it is @tests/unit/_bootstrap.php which holds some basic things like:
# including composer autoload, include BaseYii class.
public $baseConfig = '@app/config/console.php';
public $applicationClass = 'yii\console\Application';
}
```
Dont forget that you still need to include autoload and BaseYii class, like in the _bootstrap.php file (comments above).
You also can reconfigure some components for tests, for this purpose there is a ```$config``` property in the testcase.
```php
SomeOtherTest extends yii\codeception\TestCase
{
public $config = [
'components' => [
'mail' => [
'useFileTransport' => true,
],
]
];
}
```
Because of Codeception buffers all output you cant make simple ```var_dump()``` in the TestCase, instead you need to use
```Codeception\Util\Debug::debug()``` function and then run test with ```--debug``` key, for example:
```php
use \Codeception\Util\Debug;
SomeDebugTest extends yii\codeception\TestCase
{
public function testSmth()
{
Debug::debug('some my string');
Debug::debug($someArray);
Debug::debug($someObject);
}
}
```
Then run command ```php codecept.phar run --debug unit/SomeDebugTest``` (Codeception also available through composer) and you will see in output:
```html
some my string
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
)
yii\web\User Object
(
[identityClass] => app\models\User
[enableAutoLogin] =>
[loginUrl] => Array
(
[0] => site/login
)
[identityCookie] => Array
(
[name] => _identity
[httpOnly] => 1
)
[authTimeout] =>
[autoRenewCookie] => 1
[idVar] => __id
[authTimeoutVar] => __expire
[returnUrlVar] => __returnUrl
[_access:yii\web\User:private] => Array
(
)
[_identity:yii\web\User:private] =>
[_events:yii\base\Component:private] =>
[_behaviors:yii\base\Component:private] =>
)
```
For further instructions refer to the related section in the Yii Definitive Guide (https://github.com/yiisoft/yii2/blob/master/docs/guide/testing.md).
Installation
------------
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require yiisoft/yii2-codeception "*"
```
or add
```json
"yiisoft/yii2-codeception": "*"
```
to the require section of your composer.json.
<?php
namespace yii\codeception;
use Yii;
use yii\helpers\ArrayHelper;
/**
* TestCase is the base class for all codeception unit tests
*
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
class TestCase extends \PHPUnit_Framework_TestCase
{
/**
* @var array|string Your application base config that will be used for creating application each time before test.
* This can be an array or alias, pointing to the config file. For example for console application it can be
* '@tests/unit/console_bootstrap.php' that can be similar to existing unit tests bootstrap file.
*/
public static $applicationConfig = '@app/config/web.php';
/**
* @var array|string Your application config, will be merged with base config when creating application. Can be an alias too.
*/
protected $config = [];
/**
* Created application class
* @var string
*/
protected $applicationClass = 'yii\web\Application';
protected function tearDown()
{
$this->destroyApplication();
parent::tearDown();
}
/**
* Sets up `Yii::$app`.
*/
protected function mockApplication()
{
$baseConfig = is_array(static::$applicationConfig) ? static::$applicationConfig : require(Yii::getAlias(static::$applicationConfig));
$config = is_array($this->config)? $this->config : require(Yii::getAlias($this->config));
new $this->applicationClass(ArrayHelper::merge($baseConfig,$config));
}
/**
* Destroys an application created via [[mockApplication]].
*/
protected function destroyApplication()
{
\Yii::$app = null;
}
}
{
"name": "yiisoft/yii2-codeception",
"description": "The Codeception integration for the Yii framework",
"keywords": ["yii", "codeception"],
"type": "yii2-extension",
"license": "BSD-3-Clause",
"support": {
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"authors": [
{
"name": "Mark Jebri",
"email": "mark.github@yandex.ru"
}
],
"require": {
"yiisoft/yii2": "*"
},
"autoload": {
"psr-0": { "yii\\codeception\\": "" }
},
"target-dir": "yii/codeception"
}
......@@ -139,6 +139,7 @@ class QueryBuilder extends \yii\base\Object
public function buildCondition($condition)
{
static $builders = array(
'not' => 'buildNotCondition',
'and' => 'buildAndCondition',
'or' => 'buildAndCondition',
'between' => 'buildBetweenCondition',
......@@ -196,6 +197,19 @@ class QueryBuilder extends \yii\base\Object
return count($parts) === 1 ? $parts[0] : ['and' => $parts];
}
private function buildNotCondition($operator, $operands, &$params)
{
if (count($operands) != 1) {
throw new InvalidParamException("Operator '$operator' requires exactly one operand.");
}
$operand = reset($operands);
if (is_array($operand)) {
$operand = $this->buildCondition($operand, $params);
}
return [$operator => $operand];
}
private function buildAndCondition($operator, $operands)
{
$parts = [];
......
......@@ -219,6 +219,7 @@ EOF;
public function buildCondition($condition, &$columns)
{
static $builders = [
'not' => 'buildNotCondition',
'and' => 'buildAndCondition',
'or' => 'buildAndCondition',
'between' => 'buildBetweenCondition',
......@@ -269,6 +270,19 @@ EOF;
return count($parts) === 1 ? $parts[0] : '(' . implode(') and (', $parts) . ')';
}
private function buildNotCondition($operator, $operands, &$params)
{
if (count($operands) != 1) {
throw new InvalidParamException("Operator '$operator' requires exactly one operand.");
}
$operand = reset($operands);
if (is_array($operand)) {
$operand = $this->buildCondition($operand, $params);
}
return "!($operand)";
}
private function buildAndCondition($operator, $operands, &$columns)
{
$parts = [];
......
......@@ -8,17 +8,21 @@ Yii Framework 2 Change Log
- Bug #1497: Localized view files are not correctly returned (mintao)
- Bug #1500: Log messages exported to files are not separated by newlines (omnilight, qiangxue)
- Bug #1509: The SQL for creating Postgres RBAC tables is incorrect (qiangxue)
- Bug #1545: It was not possible to execute db Query twice, params where missing (cebe)
- Bug: Fixed `Call to a member function registerAssetFiles() on a non-object` in case of wrong `sourcePath` for an asset bundle (samdark)
- Bug: Fixed incorrect event name for `yii\jui\Spinner` (samdark)
- Enh #1293: Replaced Console::showProgress() with a better approach. See Console::startProgress() for details (cebe)
- Enh #1406: DB Schema support for Oracle Database (p0larbeer, qiangxue)
- Enh #1437: Added ListView::viewParams (qiangxue)
- Enh #1469: ActiveRecord::find() now works with default conditions (default scope) applied by createQuery (cebe)
- Enh #1523: Query conditions now allow to use the NOT operator (cebe)
- Enh #1552: It is now possible to use multiple bootstrap NavBar in a single page (Alex-Code)
- Enh: Added `favicon.ico` and `robots.txt` to defauly application templates (samdark)
- Enh: Added `Widget::autoIdPrefix` to support prefixing automatically generated widget IDs (qiangxue)
- Enh: Support for file aliases in console command 'message' (omnilight)
- Chg: Renamed yii\jui\Widget::clientEventsMap to clientEventMap (qiangxue)
- New #1438: [MongoDB integration](https://github.com/yiisoft/yii2-mongodb) ActiveRecord and Query (klimov-paul)
- New #1393: [Codeception testing framework integration](https://github.com/yiisoft/yii2-codeception) (Ragazzo)
2.0.0 alpha, December 1, 2013
---------------------------
......
......@@ -370,6 +370,7 @@ abstract class Application extends Module
/**
* Sets the time zone used by this application.
* This is a simple wrapper of PHP function date_default_timezone_set().
* Refer to the [php manual](http://www.php.net/manual/en/timezones.php) for available timezones.
* @param string $value the time zone used by this application.
* @see http://php.net/manual/en/function.date-default-timezone-set.php
*/
......
......@@ -122,7 +122,6 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$db = $modelClass::getDb();
}
$params = $this->params;
if ($this->sql === null) {
if ($this->from === null) {
$tableName = $modelClass::tableName();
......@@ -131,8 +130,8 @@ class ActiveQuery extends Query implements ActiveQueryInterface
}
$this->from = [$tableName];
}
list ($this->sql, $params) = $db->getQueryBuilder()->build($this);
list ($this->sql, $this->params) = $db->getQueryBuilder()->build($this);
}
return $db->createCommand($this->sql, $params);
return $db->createCommand($this->sql, $this->params);
}
}
......@@ -788,6 +788,7 @@ class QueryBuilder extends \yii\base\Object
public function buildCondition($condition, &$params)
{
static $builders = [
'NOT' => 'buildNotCondition',
'AND' => 'buildAndCondition',
'OR' => 'buildAndCondition',
'BETWEEN' => 'buildBetweenCondition',
......@@ -878,6 +879,30 @@ class QueryBuilder extends \yii\base\Object
}
/**
* Inverts an SQL expressions with `NOT` operator.
* @param string $operator the operator to use for connecting the given operands
* @param array $operands the SQL expressions to connect.
* @param array $params the binding parameters to be populated
* @return string the generated SQL expression
* @throws InvalidParamException if wrong number of operands have been given.
*/
public function buildNotCondition($operator, $operands, &$params)
{
if (count($operands) != 1) {
throw new InvalidParamException("Operator '$operator' requires exactly one operand.");
}
$operand = reset($operands);
if (is_array($operand)) {
$operand = $this->buildCondition($operand, $params);
}
if ($operand === '') {
return '';
}
return "$operator ($operand)";
}
/**
* Creates an SQL expressions with the `BETWEEN` operator.
* @param string $operator the operator to use (e.g. `BETWEEN` or `NOT BETWEEN`)
* @param array $operands the first operand is the column name. The second and third operands
......
......@@ -178,7 +178,7 @@ class BaseSecurity
/**
* Returns a secret key associated with the specified name.
* If the secret key does not exist, a random key will be generated
* and saved in the file "keys.data" under the application's runtime directory
* and saved in the file "keys.json" under the application's runtime directory
* so that the same secret key can be returned in future requests.
* @param string $name the name that is associated with the secret key
* @param integer $length the length of the key that should be generated if not exists
......
......@@ -39,6 +39,15 @@ class Formatter extends \yii\base\Formatter
*/
public $locale;
/**
* @var string|\IntlTimeZone|\DateTimeZone the timezone to use for formatting time and date values.
* This can be any value that may be passed to [date_default_timezone_set()](http://www.php.net/manual/en/function.date-default-timezone-set.php)
* e.g. `UTC`, `Europe/Berlin` or `America/Chicago`.
* Refer to the [php manual](http://www.php.net/manual/en/timezones.php) for available timezones.
* This can also be an IntlTimeZone or a DateTimeZone object.
* If not set, [[\yii\base\Application::timezone]] will be used.
*/
public $timeZone;
/**
* @var string the default format string to be used to format a date.
* This can be "short", "medium", "long", or "full", which represents a preset format of different lengths.
* It can also be a custom format as specified in the [ICU manual](http://userguide.icu-project.org/formatparse/datetime).
......@@ -84,11 +93,14 @@ class Formatter extends \yii\base\Formatter
public function init()
{
if (!extension_loaded('intl')) {
throw new InvalidConfigException('The "intl" PHP extension is not install. It is required to format data values in localized formats.');
throw new InvalidConfigException('The "intl" PHP extension is not installed. It is required to format data values in localized formats.');
}
if ($this->locale === null) {
$this->locale = Yii::$app->language;
}
if ($this->timeZone === null) {
$this->timeZone = Yii::$app->timeZone;
}
if ($this->decimalSeparator === null || $this->thousandSeparator === null) {
$formatter = new NumberFormatter($this->locale, NumberFormatter::DECIMAL);
if ($this->decimalSeparator === null) {
......@@ -125,6 +137,7 @@ class Formatter extends \yii\base\Formatter
* It can also be a custom format as specified in the [ICU manual](http://userguide.icu-project.org/formatparse/datetime).
*
* @return string the formatted result
* @throws InvalidConfigException when formatting fails due to invalid parameters.
* @see dateFormat
*/
public function asDate($value, $format = null)
......@@ -137,9 +150,9 @@ class Formatter extends \yii\base\Formatter
$format = $this->dateFormat;
}
if (isset($this->_dateFormats[$format])) {
$formatter = new IntlDateFormatter($this->locale, $this->_dateFormats[$format], IntlDateFormatter::NONE);
$formatter = new IntlDateFormatter($this->locale, $this->_dateFormats[$format], IntlDateFormatter::NONE, $this->timeZone);
} else {
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE);
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE, $this->timeZone);
if ($formatter !== null) {
$formatter->setPattern($format);
}
......@@ -166,6 +179,7 @@ class Formatter extends \yii\base\Formatter
* It can also be a custom format as specified in the [ICU manual](http://userguide.icu-project.org/formatparse/datetime).
*
* @return string the formatted result
* @throws InvalidConfigException when formatting fails due to invalid parameters.
* @see timeFormat
*/
public function asTime($value, $format = null)
......@@ -178,9 +192,9 @@ class Formatter extends \yii\base\Formatter
$format = $this->timeFormat;
}
if (isset($this->_dateFormats[$format])) {
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, $this->_dateFormats[$format]);
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, $this->_dateFormats[$format], $this->timeZone);
} else {
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE);
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE, $this->timeZone);
if ($formatter !== null) {
$formatter->setPattern($format);
}
......@@ -207,6 +221,7 @@ class Formatter extends \yii\base\Formatter
* It can also be a custom format as specified in the [ICU manual](http://userguide.icu-project.org/formatparse/datetime).
*
* @return string the formatted result
* @throws InvalidConfigException when formatting fails due to invalid parameters.
* @see datetimeFormat
*/
public function asDatetime($value, $format = null)
......@@ -219,9 +234,9 @@ class Formatter extends \yii\base\Formatter
$format = $this->datetimeFormat;
}
if (isset($this->_dateFormats[$format])) {
$formatter = new IntlDateFormatter($this->locale, $this->_dateFormats[$format], $this->_dateFormats[$format]);
$formatter = new IntlDateFormatter($this->locale, $this->_dateFormats[$format], $this->_dateFormats[$format], $this->timeZone);
} else {
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE);
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE, $this->timeZone);
if ($formatter !== null) {
$formatter->setPattern($format);
}
......
......@@ -16,6 +16,9 @@ use yii\helpers\Json;
/**
* UrlValidator validates that the attribute value is a valid http or https URL.
*
* Note that this validator only checks if the URL scheme and host part are correct.
* It does not check the rest part of a URL.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
......
......@@ -34,6 +34,7 @@ class LinkSorter extends Widget
public $attributes;
/**
* @var array HTML attributes for the sorter container tag.
* See [[yii\helpers\Html::ul()]] for special attributes.
*/
public $options = ['class' => 'sorter'];
......@@ -68,6 +69,6 @@ class LinkSorter extends Widget
foreach ($attributes as $name) {
$links[] = $this->sort->link($name);
}
return Html::ul($links, ['encode' => false]);
return Html::ul($links, array_merge($this->options, ['encode' => false]));
}
}
......@@ -28,7 +28,9 @@ class FormatterTest extends TestCase
if (!extension_loaded('intl')) {
$this->markTestSkipped('intl extension is required.');
}
$this->mockApplication();
$this->mockApplication([
'timeZone' => 'UTC',
]);
$this->formatter = new Formatter(['locale' => 'en-US']);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment