PHP Class Codeception\Module\Laravel5

Please try it and leave your feedback. The module is based on the Laravel 4 module by Davert. ## Demo project ## Status * Maintainer: **Jan-Henk Gerritsen** * Stability: **dev** * Contact: [email protected] ## Example modules: enabled: - Laravel5 ## Config * cleanup: boolean, default true - all db queries will be run in transaction, which will be rolled back at the end of test. * environment_file: string, default .env - The .env file to load for the tests. * bootstrap: string, default bootstrap/app.php - Relative path to app.php config file. * root: string, default - Root path of our application. * packages: string, default workbench - Root path of application packages (if any). ## API * app - Illuminate\Foundation\Application instance * client - BrowserKit` client ## Parts * ORM - include only haveRecord/grabRecord/seeRecord/dontSeeRecord actions
Inheritance: extends Codeception\Lib\Framework, implements Codeception\Lib\Interfaces\ActiveRecord, implements Codeception\Lib\Interfaces\PartedModule
Mostra file Open project: janhenkgerritsen/codeception-laravel5 Class Usage Examples

Public Properties

Property Type Description
$app Illuminate\Foundation\Application

Protected Properties

Property Type Description
$config array

Public Methods

Method Description
__construct ( $config = null ) Constructor.
_after ( Codeception\TestCase $test ) After hook.
_afterStep ( Codeception\Step $step ) After step hook.
_before ( Codeception\TestCase $test ) Before hook.
_initialize ( ) Initialize hook.
amLoggedAs ( Illuminate\Contracts\Auth\User | array $user, string $driver = null ) : void Set the currently logged in user for the application.
amOnAction ( $action, array $params = [] ) Opens web page by action name
amOnRoute ( $route, array $params = [] ) Opens web page using route name and parameters.
dontSeeAuthentication ( ) Check that user is not authenticated
dontSeeRecord ( $model, array $attributes = [] ) Checks that record does not exist in database.
getApplication ( ) : Illuminate\Foundation\Application Provides access the Laravel application object.
grabRecord ( $model, array $attributes = [] ) : mixed Retrieves record from database
grabService ( string $class ) : mixed Return an instance of a class from the IoC Container.
haveRecord ( $model, array $attributes = [] ) : mixed Inserts record into the database.
logout ( ) Logs user out
seeAuthentication ( ) Checks that user is authenticated
seeCurrentActionIs ( $action, array $params = [] ) Checks that current url matches action
seeCurrentRouteIs ( $route, array $params = [] ) Checks that current url matches route
seeFormErrorMessage ( string $key, string $errorMessage ) Assert that specific form error message is set in the view.
seeFormErrorMessages ( array $bindings ) Assert that specific form error messages are set in the view.
seeFormHasErrors ( ) : boolean Assert that the form errors are bound to the View.
seeInSession ( string | array $key, mixed $value = null ) : void Assert that the session has a given list of values.
seeRecord ( $model, array $attributes = [] ) Checks that record exists in database.
seeSessionHasValues ( array $bindings ) : void Assert that the session has a given list of values.

Protected Methods

Method Description
actionWithNamespace ( string $action ) : string Normalize an action to full namespaced action.
bootApplication ( ) : Illuminate\Foundation\Application Boot the Laravel application object.
findRecord ( $model, array $attributes = [] ) : mixed
getRootControllerNamespace ( ) : string Get the root controller namespace for the application.
initializeLaravel ( ) Initialize the Laravel framework.
revertErrorHandler ( ) Revert back to the Codeception error handler, becauses Laravel registers it's own error handler.

Method Details

__construct() public method

Constructor.
public __construct ( $config = null )
$config

_after() public method

After hook.
public _after ( Codeception\TestCase $test )
$test Codeception\TestCase

_afterStep() public method

After step hook.
public _afterStep ( Codeception\Step $step )
$step Codeception\Step

_before() public method

Before hook.
public _before ( Codeception\TestCase $test )
$test Codeception\TestCase

_initialize() public method

Initialize hook.
public _initialize ( )

actionWithNamespace() protected method

Normalize an action to full namespaced action.
protected actionWithNamespace ( string $action ) : string
$action string
return string

amLoggedAs() public method

Takes either an object that implements the User interface or an array of credentials.
public amLoggedAs ( Illuminate\Contracts\Auth\User | array $user, string $driver = null ) : void
$user Illuminate\Contracts\Auth\User | array
$driver string
return void

amOnAction() public method

php amOnAction('PostsController@index'); ?>
public amOnAction ( $action, array $params = [] )
$action
$params array

amOnRoute() public method

php amOnRoute('posts.create'); ?>
public amOnRoute ( $route, array $params = [] )
$route
$params array

bootApplication() protected method

Boot the Laravel application object.
protected bootApplication ( ) : Illuminate\Foundation\Application
return Illuminate\Foundation\Application

dontSeeAuthentication() public method

Check that user is not authenticated

dontSeeRecord() public method

php dontSeeRecord('users', array('name' => 'davert')); ?>
public dontSeeRecord ( $model, array $attributes = [] )
$model
$attributes array

findRecord() protected method

protected findRecord ( $model, array $attributes = [] ) : mixed
$model
$attributes array
return mixed

getApplication() public method

Provides access the Laravel application object.
public getApplication ( ) : Illuminate\Foundation\Application
return Illuminate\Foundation\Application

getRootControllerNamespace() protected method

Get the root controller namespace for the application.
protected getRootControllerNamespace ( ) : string
return string

grabRecord() public method

php grabRecord('users', array('name' => 'davert')); ?>
public grabRecord ( $model, array $attributes = [] ) : mixed
$model
$attributes array
return mixed

grabService() public method

(http://laravel.com/docs/ioc) Example php grabService('foo'); Will return an instance of FooBar, also works for singletons. ?>
public grabService ( string $class ) : mixed
$class string
return mixed

haveRecord() public method

php haveRecord('users', array('name' => 'Davert')); ?>
public haveRecord ( $model, array $attributes = [] ) : mixed
$model
$attributes array
return mixed

initializeLaravel() protected method

Initialize the Laravel framework.
protected initializeLaravel ( )

logout() public method

Logs user out
public logout ( )

revertErrorHandler() protected method

Revert back to the Codeception error handler, becauses Laravel registers it's own error handler.
protected revertErrorHandler ( )

seeAuthentication() public method

Checks that user is authenticated
public seeAuthentication ( )

seeCurrentActionIs() public method

php seeCurrentActionIs('PostsController@index'); ?>
public seeCurrentActionIs ( $action, array $params = [] )
$action
$params array

seeCurrentRouteIs() public method

php seeCurrentRouteIs('posts.index'); ?>
public seeCurrentRouteIs ( $route, array $params = [] )
$route
$params array

seeFormErrorMessage() public method

Useful for validation messages and generally messages array e.g. return Redirect::to('register')->withErrors($validator); Example of Usage php seeFormErrorMessage('username', 'Invalid Username'); ?>
public seeFormErrorMessage ( string $key, string $errorMessage )
$key string
$errorMessage string

seeFormErrorMessages() public method

Useful for validation messages and generally messages array e.g. return Redirect::to('register')->withErrors($validator); Example of Usage php seeFormErrorMessages(array('username'=>'Invalid Username')); ?>
public seeFormErrorMessages ( array $bindings )
$bindings array

seeFormHasErrors() public method

Assert that the form errors are bound to the View.
public seeFormHasErrors ( ) : boolean
return boolean

seeInSession() public method

Assert that the session has a given list of values.
public seeInSession ( string | array $key, mixed $value = null ) : void
$key string | array
$value mixed
return void

seeRecord() public method

php $I->seeRecord('users', array('name' => 'davert'));
public seeRecord ( $model, array $attributes = [] )
$model
$attributes array

seeSessionHasValues() public method

Assert that the session has a given list of values.
public seeSessionHasValues ( array $bindings ) : void
$bindings array
return void

Property Details

$app public_oe property

public Application,Illuminate\Foundation $app
return Illuminate\Foundation\Application

$config protected_oe property

protected array $config
return array