diff --git a/.gitignore b/.gitignore index 50a4392b46..b8e7b848f2 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ app/storage/firefly-export* .vagrant firefly-iii-import-*.json -tests/_output/* \ No newline at end of file +tests/_output/* +testing.sqlite diff --git a/app/config/homestead/cache.php b/app/config/homestead/cache.php new file mode 100644 index 0000000000..8fa089055b --- /dev/null +++ b/app/config/homestead/cache.php @@ -0,0 +1,12 @@ + 'file', + 'path' => storage_path() . '/cache', + 'connection' => null, + 'table' => 'cache', + 'memcached' => [ + ['host' => '127.0.0.1', 'port' => 11211, 'weight' => 100], + ], + 'prefix' => 'laravel', +]; diff --git a/app/config/testing/app.php b/app/config/testing/app.php new file mode 100644 index 0000000000..e729eb5ab7 --- /dev/null +++ b/app/config/testing/app.php @@ -0,0 +1,2 @@ + 'debug',]; \ No newline at end of file diff --git a/app/config/testing/database.php b/app/config/testing/database.php index 8448619ce0..dce7200371 100644 --- a/app/config/testing/database.php +++ b/app/config/testing/database.php @@ -4,8 +4,9 @@ return [ 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', - 'database' => ':memory:', + 'database' => 'tests/_data/testing.sqlite', 'prefix' => '' - ], + ] + ] ]; \ No newline at end of file diff --git a/app/config/testing/mail.php b/app/config/testing/mail.php new file mode 100644 index 0000000000..d2df78f4cd --- /dev/null +++ b/app/config/testing/mail.php @@ -0,0 +1,13 @@ + 'smtp', + 'host' => '', + 'port' => 587, + 'from' => ['address' => '', 'name' => 'Firefly III'], + 'encryption' => 'tls', + 'username' => '', + 'password' => '', + 'sendmail' => '/usr/sbin/sendmail -bs', + 'pretend' => true, +]; diff --git a/app/database/migrations/2014_06_27_164042_create_transaction_currencies_table.php b/app/database/migrations/2014_06_27_164042_create_transaction_currencies_table.php index 04e34c4863..be165577cb 100644 --- a/app/database/migrations/2014_06_27_164042_create_transaction_currencies_table.php +++ b/app/database/migrations/2014_06_27_164042_create_transaction_currencies_table.php @@ -32,6 +32,7 @@ class CreateTransactionCurrenciesTable extends Migration 'transaction_currencies', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); + $table->softDeletes(); $table->string('code', 3); } ); diff --git a/app/database/seeds/DefaultUserSeeder.php b/app/database/seeds/DefaultUserSeeder.php index 729914f8ad..1b484c895c 100644 --- a/app/database/seeds/DefaultUserSeeder.php +++ b/app/database/seeds/DefaultUserSeeder.php @@ -8,7 +8,7 @@ class DefaultUserSeeder extends Seeder public function run() { DB::table('users')->delete(); - if (App::environment() == 'homestead') { + if (App::environment() == 'testing') { User::create( ['email' => 'thegrumpydictator@gmail.com', 'password' => 'james', 'reset' => null, 'remember_token' => null, 'migrated' => 0] diff --git a/app/database/seeds/TestContentSeeder.php b/app/database/seeds/TestContentSeeder.php index 5fe1700ff3..202b8ebd11 100644 --- a/app/database/seeds/TestContentSeeder.php +++ b/app/database/seeds/TestContentSeeder.php @@ -7,7 +7,7 @@ class TestContentSeeder extends Seeder public function run() { - if (App::environment() == 'homestead') { + if (App::environment() == 'testing') { $assetType = AccountType::whereType('Asset account')->first(); $expenseType = AccountType::whereType('Expense account')->first(); diff --git a/app/views/layouts/default.blade.php b/app/views/layouts/default.blade.php index e215c4b029..ffad378639 100644 --- a/app/views/layouts/default.blade.php +++ b/app/views/layouts/default.blade.php @@ -25,6 +25,8 @@ + +
diff --git a/app/views/layouts/guest.blade.php b/app/views/layouts/guest.blade.php index 8485ddaccb..85966199ce 100644 --- a/app/views/layouts/guest.blade.php +++ b/app/views/layouts/guest.blade.php @@ -18,6 +18,8 @@ + +
diff --git a/bootstrap/start.php b/bootstrap/start.php index 479b986f35..8ae272f09c 100644 --- a/bootstrap/start.php +++ b/bootstrap/start.php @@ -93,6 +93,7 @@ Event::subscribe('FireflyIII\Event\Budget'); Event::subscribe('FireflyIII\Event\TransactionJournal'); Event::subscribe('FireflyIII\Event\Transaction'); Event::subscribe('FireflyIII\Event\Account'); +Event::subscribe('FireflyIII\Event\Event'); // event that creates a relationship between transaction journals and recurring events when created. // event that updates the relationship between transaction journals and recurring events when edited. diff --git a/codeception.yml b/codeception.yml index 306e739692..4acd5b63a3 100644 --- a/codeception.yml +++ b/codeception.yml @@ -9,9 +9,23 @@ settings: colors: true memory_limit: 1024M modules: - config: - Db: - dsn: '' - user: '' - password: '' - dump: tests/_data/dump.sql + config: + Db: + dsn: 'sqlite:tests/_data/testing.sqlite' + user: '' + password: '' + dump: + cleanup: false + populate: false +coverage: + enabled: true +whitelist: + include: + - app/* + exclude: + - app/storage/* + blacklist: + include: + - app/controllers/* + exclude: + - app/controllers/BaseController.php \ No newline at end of file diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index 243f9c85bc..14f1eda6e0 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -1,2 +1,8 @@ haveInDatabase('users', array('name' => 'miles', 'email' => 'miles@davis.com')); + * ?> + * ``` + * + * @param $table + * @param array $data + * @return integer $id + * @see \Codeception\Module\Db::haveInDatabase() + */ + public function haveInDatabase($table, $data) { + return $this->scenario->runStep(new \Codeception\Step\Action('haveInDatabase', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if a row with given column values exists. + * Provide table name and column values. + * + * Example: + * + * ``` php + * seeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); + * + * ``` + * Will generate: + * + * ``` sql + * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' + * ``` + * Fails if no such user found. + * + * @param $table + * @param array $criteria + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Db::seeInDatabase() + */ + public function canSeeInDatabase($table, $criteria = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInDatabase', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if a row with given column values exists. + * Provide table name and column values. + * + * Example: + * + * ``` php + * seeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); + * + * ``` + * Will generate: + * + * ``` sql + * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' + * ``` + * Fails if no such user found. + * + * @param $table + * @param array $criteria + * @see \Codeception\Module\Db::seeInDatabase() + */ + public function seeInDatabase($table, $criteria = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInDatabase', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Effect is opposite to ->seeInDatabase + * + * Checks if there is no record with such column values in database. + * Provide table name and column values. + * + * Example: + * + * ``` php + * dontSeeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); + * + * ``` + * Will generate: + * + * ``` sql + * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' + * ``` + * Fails if such user was found. + * + * @param $table + * @param array $criteria + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Db::dontSeeInDatabase() + */ + public function cantSeeInDatabase($table, $criteria = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInDatabase', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Effect is opposite to ->seeInDatabase + * + * Checks if there is no record with such column values in database. + * Provide table name and column values. + * + * Example: + * + * ``` php + * dontSeeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); + * + * ``` + * Will generate: + * + * ``` sql + * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' + * ``` + * Fails if such user was found. + * + * @param $table + * @param array $criteria + * @see \Codeception\Module\Db::dontSeeInDatabase() + */ + public function dontSeeInDatabase($table, $criteria = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInDatabase', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Fetches a single column value from a database. + * Provide table name, desired column and criteria. + * + * Example: + * + * ``` php + * grabFromDatabase('users', 'email', array('name' => 'Davert')); + * + * ``` + * + * @version 1.1 + * + * @param $table + * @param $column + * @param array $criteria + * + * @return mixed + * @see \Codeception\Module\Db::grabFromDatabase() + */ + public function grabFromDatabase($table, $column, $criteria = null) { + return $this->scenario->runStep(new \Codeception\Step\Action('grabFromDatabase', func_get_args())); + } + + /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -355,4 +524,1998 @@ class FunctionalTester extends \Codeception\Actor public function writeToFile($filename, $contents) { return $this->scenario->runStep(new \Codeception\Step\Action('writeToFile', func_get_args())); } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Enable Laravel filters for next requests. + * @see \Codeception\Module\Laravel4::haveEnabledFilters() + */ + public function haveEnabledFilters() { + return $this->scenario->runStep(new \Codeception\Step\Action('haveEnabledFilters', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Disable Laravel filters for next requests. + * @see \Codeception\Module\Laravel4::haveDisabledFilters() + */ + public function haveDisabledFilters() { + return $this->scenario->runStep(new \Codeception\Step\Action('haveDisabledFilters', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens web page using route name and parameters. + * + * ```php + * amOnRoute('posts.create'); + * ?> + * ``` + * + * @param $route + * @param array $params + * @see \Codeception\Module\Laravel4::amOnRoute() + */ + public function amOnRoute($route, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\Condition('amOnRoute', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens web page by action name + * + * ```php + * amOnAction('PostsController@index'); + * ?> + * ``` + * + * @param $action + * @param array $params + * @see \Codeception\Module\Laravel4::amOnAction() + */ + public function amOnAction($action, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\Condition('amOnAction', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches route + * + * ```php + * seeCurrentRouteIs('posts.index'); + * ?> + * ``` + * @param $route + * @param array $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeCurrentRouteIs() + */ + public function canSeeCurrentRouteIs($route, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentRouteIs', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches route + * + * ```php + * seeCurrentRouteIs('posts.index'); + * ?> + * ``` + * @param $route + * @param array $params + * @see \Codeception\Module\Laravel4::seeCurrentRouteIs() + */ + public function seeCurrentRouteIs($route, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentRouteIs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches action + * + * ```php + * seeCurrentActionIs('PostsController@index'); + * ?> + * ``` + * + * @param $action + * @param array $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeCurrentActionIs() + */ + public function canSeeCurrentActionIs($action, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentActionIs', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches action + * + * ```php + * seeCurrentActionIs('PostsController@index'); + * ?> + * ``` + * + * @param $action + * @param array $params + * @see \Codeception\Module\Laravel4::seeCurrentActionIs() + */ + public function seeCurrentActionIs($action, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentActionIs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has a given list of values. + * + * @param string|array $key + * @param mixed $value + * @return void + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeInSession() + */ + public function canSeeInSession($key, $value = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInSession', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has a given list of values. + * + * @param string|array $key + * @param mixed $value + * @return void + * @see \Codeception\Module\Laravel4::seeInSession() + */ + public function seeInSession($key, $value = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInSession', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has a given list of values. + * + * @param array $bindings + * @return void + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeSessionHasValues() + */ + public function canSeeSessionHasValues($bindings) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeSessionHasValues', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has a given list of values. + * + * @param array $bindings + * @return void + * @see \Codeception\Module\Laravel4::seeSessionHasValues() + */ + public function seeSessionHasValues($bindings) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeSessionHasValues', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that Session has error messages + * The seeSessionHasValues cannot be used, as Message bag Object is returned by Laravel4 + * + * Useful for validation messages and generally messages array + * e.g. + * return `Redirect::to('register')->withErrors($validator);` + * + * Example of Usage + * + * ``` php + * seeSessionErrorMessage(array('username'=>'Invalid Username')); + * ?> + * ``` + * @param array $bindings + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeSessionErrorMessage() + */ + public function canSeeSessionErrorMessage($bindings) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeSessionErrorMessage', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that Session has error messages + * The seeSessionHasValues cannot be used, as Message bag Object is returned by Laravel4 + * + * Useful for validation messages and generally messages array + * e.g. + * return `Redirect::to('register')->withErrors($validator);` + * + * Example of Usage + * + * ``` php + * seeSessionErrorMessage(array('username'=>'Invalid Username')); + * ?> + * ``` + * @param array $bindings + * @see \Codeception\Module\Laravel4::seeSessionErrorMessage() + */ + public function seeSessionErrorMessage($bindings) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeSessionErrorMessage', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has errors bound. + * + * @return bool + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeSessionHasErrors() + */ + public function canSeeSessionHasErrors() { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeSessionHasErrors', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has errors bound. + * + * @return bool + * @see \Codeception\Module\Laravel4::seeSessionHasErrors() + */ + public function seeSessionHasErrors() { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeSessionHasErrors', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Set the currently logged in user for the application. + * Takes either `UserInterface` instance or array of credentials. + * + * @param \Illuminate\Auth\UserInterface|array $user + * @param string $driver + * @return void + * @see \Codeception\Module\Laravel4::amLoggedAs() + */ + public function amLoggedAs($user, $driver = null) { + return $this->scenario->runStep(new \Codeception\Step\Condition('amLoggedAs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Logs user out + * @see \Codeception\Module\Laravel4::logout() + */ + public function logout() { + return $this->scenario->runStep(new \Codeception\Step\Action('logout', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that user is authenticated + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeAuthentication() + */ + public function canSeeAuthentication() { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeAuthentication', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that user is authenticated + * @see \Codeception\Module\Laravel4::seeAuthentication() + */ + public function seeAuthentication() { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeAuthentication', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that user is not authenticated + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::dontSeeAuthentication() + */ + public function cantSeeAuthentication() { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeAuthentication', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that user is not authenticated + * @see \Codeception\Module\Laravel4::dontSeeAuthentication() + */ + public function dontSeeAuthentication() { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeAuthentication', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Return an instance of a class from the IoC Container. + * (http://laravel.com/docs/ioc) + * + * Example + * ``` php + * grabService('foo'); + * + * // Will return an instance of FooBar, also works for singletons. + * ?> + * ``` + * + * @param string $class + * @return mixed + * @see \Codeception\Module\Laravel4::grabService() + */ + public function grabService($class) { + return $this->scenario->runStep(new \Codeception\Step\Action('grabService', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Inserts record into the database. + * + * ``` php + * haveRecord('users', array('name' => 'Davert')); + * ?> + * ``` + * + * @param $model + * @param array $attributes + * @return mixed + * @see \Codeception\Module\Laravel4::haveRecord() + */ + public function haveRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\Action('haveRecord', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record exists in database. + * + * ``` php + * $I->seeRecord('users', array('name' => 'davert')); + * ``` + * + * @param $model + * @param array $attributes + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeRecord() + */ + public function canSeeRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeRecord', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record exists in database. + * + * ``` php + * $I->seeRecord('users', array('name' => 'davert')); + * ``` + * + * @param $model + * @param array $attributes + * @see \Codeception\Module\Laravel4::seeRecord() + */ + public function seeRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeRecord', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record does not exist in database. + * + * ``` php + * dontSeeRecord('users', array('name' => 'davert')); + * ?> + * ``` + * + * @param $model + * @param array $attributes + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::dontSeeRecord() + */ + public function cantSeeRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeRecord', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record does not exist in database. + * + * ``` php + * dontSeeRecord('users', array('name' => 'davert')); + * ?> + * ``` + * + * @param $model + * @param array $attributes + * @see \Codeception\Module\Laravel4::dontSeeRecord() + */ + public function dontSeeRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeRecord', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Retrieves record from database + * + * ``` php + * grabRecord('users', array('name' => 'davert')); + * ?> + * ``` + * + * @param $model + * @param array $attributes + * @return mixed + * @see \Codeception\Module\Laravel4::grabRecord() + */ + public function grabRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\Action('grabRecord', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Authenticates user for HTTP_AUTH + * + * @param $username + * @param $password + * @see \Codeception\Lib\InnerBrowser::amHttpAuthenticated() + */ + public function amHttpAuthenticated($username, $password) { + return $this->scenario->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens the page. + * Requires relative uri as parameter + * + * Example: + * + * ``` php + * amOnPage('/'); + * // opens /register page + * $I->amOnPage('/register'); + * ?> + * ``` + * + * @param $page + * @see \Codeception\Lib\InnerBrowser::amOnPage() + */ + public function amOnPage($page) { + return $this->scenario->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); + } + + + /** + * [!] 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 + * 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'); + * // using strict locator + * $I->click(['link' => 'Login']); + * ?> + * ``` + * + * @param $link + * @param $context + * @see \Codeception\Lib\InnerBrowser::click() + */ + public function click($link, $context = null) { + return $this->scenario->runStep(new \Codeception\Step\Action('click', func_get_args())); + } + + + /** + * [!] 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 + * 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\Lib\InnerBrowser::see() + */ + public function canSee($text, $selector = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); + } + /** + * [!] 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 + * 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\Lib\InnerBrowser::see() + */ + public function see($text, $selector = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('see', func_get_args())); + } + + + /** + * [!] 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 + * 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\Lib\InnerBrowser::dontSee() + */ + public function cantSee($text, $selector = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); + } + /** + * [!] 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 + * 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\Lib\InnerBrowser::dontSee() + */ + public function dontSee($text, $selector = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); + } + + + /** + * [!] 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 + * seeLink('Logout'); // matches Logout + * $I->seeLink('Logout','/logout'); // matches Logout + * ?> + * ``` + * + * @param $text + * @param null $url + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeLink() + */ + public function canSeeLink($text, $url = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); + } + /** + * [!] 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 + * seeLink('Logout'); // matches Logout + * $I->seeLink('Logout','/logout'); // matches Logout + * ?> + * ``` + * + * @param $text + * @param null $url + * @see \Codeception\Lib\InnerBrowser::seeLink() + */ + public function seeLink($text, $url = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); + } + + + /** + * [!] 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 + * 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\Lib\InnerBrowser::dontSeeLink() + */ + public function cantSeeLink($text, $url = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); + } + /** + * [!] 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 + * dontSeeLink('Logout'); // I suppose user is not logged in + * ?> + * ``` + * + * @param $text + * @param null $url + * @see \Codeception\Lib\InnerBrowser::dontSeeLink() + */ + public function dontSeeLink($text, $url = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current uri contains a value + * + * ``` php + * seeInCurrentUrl('home'); + * // to match: /users/1 + * $I->seeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() + */ + public function canSeeInCurrentUrl($uri) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current uri contains a value + * + * ``` php + * seeInCurrentUrl('home'); + * // to match: /users/1 + * $I->seeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() + */ + public function seeInCurrentUrl($uri) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current uri does not contain a value + * + * ``` php + * dontSeeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() + */ + public function cantSeeInCurrentUrl($uri) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current uri does not contain a value + * + * ``` php + * dontSeeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() + */ + public function dontSeeInCurrentUrl($uri) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url is equal to value. + * Unlike `seeInCurrentUrl` performs a strict check. + * + * ``` php + * seeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() + */ + public function canSeeCurrentUrlEquals($uri) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url is equal to value. + * Unlike `seeInCurrentUrl` performs a strict check. + * + * ``` php + * seeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() + */ + public function seeCurrentUrlEquals($uri) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url is not equal to value. + * Unlike `dontSeeInCurrentUrl` performs a strict check. + * + * ``` php + * dontSeeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() + */ + public function cantSeeCurrentUrlEquals($uri) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url is not equal to value. + * Unlike `dontSeeInCurrentUrl` performs a strict check. + * + * ``` php + * dontSeeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() + */ + public function dontSeeCurrentUrlEquals($uri) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url is matches a RegEx value + * + * ``` php + * seeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() + */ + public function canSeeCurrentUrlMatches($uri) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url is matches a RegEx value + * + * ``` php + * seeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() + */ + public function seeCurrentUrlMatches($uri) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url does not match a RegEx value + * + * ``` php + * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() + */ + public function cantSeeCurrentUrlMatches($uri) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url does not match a RegEx value + * + * ``` php + * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() + */ + public function dontSeeCurrentUrlMatches($uri) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Takes a parameters from current URI by RegEx. + * If no url provided returns full URI. + * + * ``` php + * grabFromCurrentUrl('~$/user/(\d+)/~'); + * $uri = $I->grabFromCurrentUrl(); + * ?> + * ``` + * + * @param null $uri + * + * @internal param $url + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() + */ + public function grabFromCurrentUrl($uri = null) { + return $this->scenario->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert if the specified checkbox is checked. + * Use css selector or xpath to match. + * + * Example: + * + * ``` php + * 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\Lib\InnerBrowser::seeCheckboxIsChecked() + */ + public function canSeeCheckboxIsChecked($checkbox) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert if the specified checkbox is checked. + * Use css selector or xpath to match. + * + * Example: + * + * ``` php + * 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\Lib\InnerBrowser::seeCheckboxIsChecked() + */ + public function seeCheckboxIsChecked($checkbox) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert if the specified checkbox is unchecked. + * Use css selector or xpath to match. + * + * Example: + * + * ``` php + * 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\Lib\InnerBrowser::dontSeeCheckboxIsChecked() + */ + public function cantSeeCheckboxIsChecked($checkbox) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert if the specified checkbox is unchecked. + * Use css selector or xpath to match. + * + * Example: + * + * ``` php + * 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\Lib\InnerBrowser::dontSeeCheckboxIsChecked() + */ + public function dontSeeCheckboxIsChecked($checkbox) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); + } + + + /** + * [!] 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 + * 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'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInField() + */ + public function canSeeInField($field, $value) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); + } + /** + * [!] 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 + * 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'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::seeInField() + */ + public function seeInField($field, $value) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); + } + + + /** + * [!] 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 + * 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'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInField() + */ + public function cantSeeInField($field, $value) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); + } + /** + * [!] 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 + * 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'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::dontSeeInField() + */ + public function dontSeeInField($field, $value) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); + } + + + /** + * [!] 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. + * + * You can optionally specify what button's value to include + * in the request with the last parameter as an alternative to + * explicitly setting its value in the second parameter, as + * button values are not otherwise included in the request. + * + * Examples: + * + * ``` php + * submitForm('#login', array('login' => 'davert', 'password' => '123456')); + * // or + * $I->submitForm('#login', array('login' => 'davert', 'password' => '123456'), 'submitButtonName'); + * + * ``` + * + * For a sample Sign Up form: + * + * ``` html + *
+ * Login:
+ * Password:
+ * Do you agree to out terms?
+ * Select pricing plan + * + *
+ * ``` + * You could write the following to submit it: + * + * ``` php + * submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true)), 'submitButton'); + * + * ``` + * Note that "2" will be the submitted value for the "plan" field, as it is the selected option. + * + * You can also emulate a JavaScript submission by not specifying any buttons in the third parameter to submitForm. + * + * ```php + * submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true))); + * + * ``` + * + * @param $selector + * @param $params + * @param $button + * @see \Codeception\Lib\InnerBrowser::submitForm() + */ + public function submitForm($selector, $params, $button = null) { + return $this->scenario->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Fills a text field or textarea with value. + * + * Example: + * + * ``` php + * fillField("//input[@type='text']", "Hello World!"); + * $I->fillField(['name' => 'email'], 'jon@mail.com'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::fillField() + */ + public function fillField($field, $value) { + return $this->scenario->runStep(new \Codeception\Step\Action('fillField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Selects an option in select tag or in radio button group. + * + * Example: + * + * ``` php + * 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 + * selectOption('Which OS do you use?', array('Windows','Linux')); + * ?> + * ``` + * + * @param $select + * @param $option + * @see \Codeception\Lib\InnerBrowser::selectOption() + */ + public function selectOption($select, $option) { + return $this->scenario->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Ticks a checkbox. + * For radio buttons use `selectOption` method. + * + * Example: + * + * ``` php + * checkOption('#agree'); + * ?> + * ``` + * + * @param $option + * @see \Codeception\Lib\InnerBrowser::checkOption() + */ + public function checkOption($option) { + return $this->scenario->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Unticks a checkbox. + * + * Example: + * + * ``` php + * uncheckOption('#notify'); + * ?> + * ``` + * + * @param $option + * @see \Codeception\Lib\InnerBrowser::uncheckOption() + */ + public function uncheckOption($option) { + return $this->scenario->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Attaches file from Codeception data directory to upload field. + * + * Example: + * + * ``` php + * attachFile('input[@type="file"]', 'prices.xls'); + * ?> + * ``` + * + * @param $field + * @param $filename + * @see \Codeception\Lib\InnerBrowser::attachFile() + */ + public function attachFile($field, $filename) { + return $this->scenario->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); + } + + + /** + * [!] 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\Lib\InnerBrowser::sendAjaxGetRequest() + */ + public function sendAjaxGetRequest($uri, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args())); + } + + + /** + * [!] 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 + * sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST + * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET + * + * ``` + * + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() + */ + public function sendAjaxPostRequest($uri, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends an ajax request with specified method and params. + * + * Example: + * + * You need to perform an ajax request specifying the HTTP method. + * + * ``` php + * sendAjaxRequest('PUT', '/posts/7', array('title' => 'new title')); + * + * ``` + * + * @param $method + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest() + */ + public function sendAjaxRequest($method, $uri, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args())); + } + + + /** + * [!] 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 + * grabTextFrom('h1'); + * $heading = $I->grabTextFrom('descendant-or-self::h1'); + * $value = $I->grabTextFrom('~ + * ``` + * + * @param $cssOrXPathOrRegex + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabTextFrom() + */ + public function grabTextFrom($cssOrXPathOrRegex) { + return $this->scenario->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Grabs attribute value from an element. + * Fails if element is not found. + * + * ``` php + * grabAttributeFrom('#tooltip', 'title'); + * ?> + * ``` + * + * + * @param $cssOrXpath + * @param $attribute + * @internal param $element + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom() + */ + public function grabAttributeFrom($cssOrXpath, $attribute) { + return $this->scenario->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * @param $field + * + * @return array|mixed|null|string + * @see \Codeception\Lib\InnerBrowser::grabValueFrom() + */ + public function grabValueFrom($field) { + return $this->scenario->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Sets a cookie. + * + * @param $cookie + * @param $value + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::setCookie() + */ + public function setCookie($name, $val) { + return $this->scenario->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Grabs a cookie value. + * + * @param $cookie + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabCookie() + */ + public function grabCookie($name) { + return $this->scenario->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); + } + + + /** + * [!] 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\Lib\InnerBrowser::seeCookie() + */ + public function canSeeCookie($name) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that cookie is set. + * + * @param $cookie + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeCookie() + */ + public function seeCookie($name) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); + } + + + /** + * [!] 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\Lib\InnerBrowser::dontSeeCookie() + */ + public function cantSeeCookie($name) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that cookie doesn't exist + * + * @param $cookie + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() + */ + public function dontSeeCookie($name) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Unsets cookie + * + * @param $cookie + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::resetCookie() + */ + public function resetCookie($name) { + return $this->scenario->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if element exists on a page, matching it by CSS or XPath. + * You can also specify expected attributes of this element. + * + * ``` php + * seeElement('.error'); + * $I->seeElement('//form/input[1]'); + * $I->seeElement('input', ['name' => 'login']); + * $I->seeElement('input', ['value' => '123456']); + * + * // strict locator in first arg, attributes in second + * $I->seeElement(['css' => 'form input'], ['name' => 'login']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * @return + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeElement() + */ + public function canSeeElement($selector, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if element exists on a page, matching it by CSS or XPath. + * You can also specify expected attributes of this element. + * + * ``` php + * seeElement('.error'); + * $I->seeElement('//form/input[1]'); + * $I->seeElement('input', ['name' => 'login']); + * $I->seeElement('input', ['value' => '123456']); + * + * // strict locator in first arg, attributes in second + * $I->seeElement(['css' => 'form input'], ['name' => 'login']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * @return + * @see \Codeception\Lib\InnerBrowser::seeElement() + */ + public function seeElement($selector, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); + } + + + /** + * [!] 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 + * You can also specify expected attributes of this element. + * + * Example: + * + * ``` php + * dontSeeElement('.error'); + * $I->dontSeeElement('//form/input[1]'); + * $I->dontSeeElement('input', ['name' => 'login']); + * $I->dontSeeElement('input', ['value' => '123456']); + * ?> + * ``` + * + * @param $selector + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeElement() + */ + public function cantSeeElement($selector, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); + } + /** + * [!] 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 + * You can also specify expected attributes of this element. + * + * Example: + * + * ``` php + * dontSeeElement('.error'); + * $I->dontSeeElement('//form/input[1]'); + * $I->dontSeeElement('input', ['name' => 'login']); + * $I->dontSeeElement('input', ['value' => '123456']); + * ?> + * ``` + * + * @param $selector + * @see \Codeception\Lib\InnerBrowser::dontSeeElement() + */ + public function dontSeeElement($selector, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Tests number of $elements on page + * + * ``` php + * seeNumberOfElements('tr', 10); + * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements + * ?> + * ``` + * @param $selector + * @param mixed $expected: + * - string: strict number + * - array: range of numbers [0,10] + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() + */ + public function canSeeNumberOfElements($selector, $expected) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Tests number of $elements on page + * + * ``` php + * seeNumberOfElements('tr', 10); + * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements + * ?> + * ``` + * @param $selector + * @param mixed $expected: + * - string: strict number + * - array: range of numbers [0,10] + * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() + */ + public function seeNumberOfElements($selector, $expected) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeNumberOfElements', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if option is selected in select field. + * + * ``` php + * seeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() + */ + public function canSeeOptionIsSelected($select, $optionText) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if option is selected in select field. + * + * ``` php + * seeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() + */ + public function seeOptionIsSelected($select, $optionText) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if option is not selected in select field. + * + * ``` php + * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() + */ + public function cantSeeOptionIsSelected($select, $optionText) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if option is not selected in select field. + * + * ``` php + * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() + */ + public function dontSeeOptionIsSelected($select, $optionText) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); + } + + + /** + * [!] 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\Lib\InnerBrowser::seePageNotFound() + */ + public function canSeePageNotFound() { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Asserts that current page has 404 response status code. + * @see \Codeception\Lib\InnerBrowser::seePageNotFound() + */ + public function seePageNotFound() { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args())); + } + + + /** + * [!] 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\Lib\InnerBrowser::seeResponseCodeIs() + */ + public function canSeeResponseCodeIs($code) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that response code is equal to value provided. + * + * @param $code + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() + */ + public function seeResponseCodeIs($code) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that page title contains text. + * + * ``` php + * seeInTitle('Blog - Post #1'); + * ?> + * ``` + * + * @param $title + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInTitle() + */ + public function canSeeInTitle($title) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that page title contains text. + * + * ``` php + * seeInTitle('Blog - Post #1'); + * ?> + * ``` + * + * @param $title + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeInTitle() + */ + public function seeInTitle($title) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args())); + } + + + /** + * [!] 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\Lib\InnerBrowser::dontSeeInTitle() + */ + public function cantSeeInTitle($title) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that page title does not contain text. + * + * @param $title + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() + */ + public function dontSeeInTitle($title) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); + } } diff --git a/tests/functional/LoginCept.php b/tests/functional/LoginCept.php new file mode 100644 index 0000000000..2f480a5402 --- /dev/null +++ b/tests/functional/LoginCept.php @@ -0,0 +1,3 @@ +wantTo('perform actions and see result'); diff --git a/tests/functional/RegisterCept.php b/tests/functional/RegisterCept.php new file mode 100644 index 0000000000..9b6724b321 --- /dev/null +++ b/tests/functional/RegisterCept.php @@ -0,0 +1,7 @@ +wantTo('register a new account'); +$I->amOnPage('/register'); +$I->submitForm('#register', ['email' => 'noreply@gmail.com']); +$I->see('Password sent!'); +$I->seeInDatabase('users', ['email' => 'noreply@gmail.com']); \ No newline at end of file diff --git a/tests/unit/UnitTester.php b/tests/unit/UnitTester.php index 67d06cdad3..5d0cb99bb4 100644 --- a/tests/unit/UnitTester.php +++ b/tests/unit/UnitTester.php @@ -1,4 +1,4 @@ -