PHP Class Neos\Flow\Tests\FunctionalTestCase

Subclass this base class if you want to take advantage of the framework capabilities, for example are in need of the object manager.
Inheritance: extends BaseTestCase
Show file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$authenticationManager Neos\Flow\Security\Authentication\AuthenticationManagerInterface
$bootstrap Neos\Flow\Core\Bootstrap
$browser Neos\Flow\Http\Client\Browser Contains a virtual, preinitialized browser
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface A functional instance of the Object Manager, for use in concrete test cases.
$persistenceManager Neos\Flow\Persistence\PersistenceManagerInterface
$policyService Neos\Flow\Security\Policy\PolicyService
$privilegeManager Neos\Flow\Security\Authorization\PrivilegeManagerInterface
$router Neos\Flow\Mvc\Routing\Router Contains the router instance used in the browser's request engine
$securityContext Neos\Flow\Security\Context
$testablePersistenceEnabled boolean If enabled, this test case will automatically run the compile() method on the Persistence Manager before running a test.
$testableSecurityEnabled boolean Note: this will implicitly enable testable HTTP as well.
$testingProvider Neos\Flow\Security\Authentication\Provider\TestingProvider

Public Methods

Method Description
setUp ( ) : void Sets up test requirements depending on the enabled tests.
setUpBeforeClass ( ) : void Initialize Flow
tearDown ( ) : void Tears down test requirements depending on the enabled tests

Protected Methods

Method Description
authenticateAccount ( Account $account ) : void Prepares the environment for and conducts an account authentication
authenticateRoles ( array $roleNames ) : Account Creates a new account, assigns it the given roles and authenticates it.
cleanupPersistentResourcesDirectory ( ) : void Cleans up the directory for storing persistent resources during testing
disableAuthorization ( ) : void Disables authorization for the current test
emitFunctionalTestTearDown ( ) : void Signals that the functional test case has been executed
registerRoute ( string $name, string $uriPattern, array $defaults, boolean $appendExceedingArguments = false, array $httpMethods = null ) : Route Adds a route that can be used in the functional tests
route ( Request $httpRequest ) : ActionRequest
setupHttp ( ) : void Sets up a virtual browser and web environment for seamless HTTP and MVC related tests.
setupSecurity ( ) : void Sets up security test requirements
setupSuperGlobals ( ) : void Setup super global PHP variables mocking a standard http request.
tearDownSecurity ( ) : void Resets security test requirements

Method Details

authenticateAccount() protected method

Prepares the environment for and conducts an account authentication
protected authenticateAccount ( Account $account ) : void
$account Neos\Flow\Security\Account
return void

authenticateRoles() protected method

The created account is returned for further modification, for example for attaching a Party object to it.
protected authenticateRoles ( array $roleNames ) : Account
$roleNames array A list of roles the new account should have
return Neos\Flow\Security\Account The created account

cleanupPersistentResourcesDirectory() protected method

Cleans up the directory for storing persistent resources during testing

disableAuthorization() protected method

Disables authorization for the current test
protected disableAuthorization ( ) : void
return void

emitFunctionalTestTearDown() protected method

Signals that the functional test case has been executed
protected emitFunctionalTestTearDown ( ) : void
return void

registerRoute() protected method

Adds a route that can be used in the functional tests
protected registerRoute ( string $name, string $uriPattern, array $defaults, boolean $appendExceedingArguments = false, array $httpMethods = null ) : Route
$name string Name of the route
$uriPattern string The uriPattern property of the route
$defaults array An array of defaults declarations
$appendExceedingArguments boolean If exceeding arguments may be appended
$httpMethods array An array of accepted http methods
return Neos\Flow\Mvc\Routing\Route

route() protected method

protected route ( Request $httpRequest ) : ActionRequest
$httpRequest Neos\Flow\Http\Request
return Neos\Flow\Mvc\ActionRequest

setUp() public method

If you override this method, don't forget to call parent::setUp() in your own implementation.
public setUp ( ) : void
return void

setUpBeforeClass() public static method

Initialize Flow
public static setUpBeforeClass ( ) : void
return void

setupHttp() protected method

Sets up a virtual browser and web environment for seamless HTTP and MVC related tests.
protected setupHttp ( ) : void
return void

setupSecurity() protected method

Security is based on action requests so we need a working route for the TestingProvider.
protected setupSecurity ( ) : void
return void

setupSuperGlobals() protected static method

Setup super global PHP variables mocking a standard http request.
protected static setupSuperGlobals ( ) : void
return void

tearDown() public method

Note: tearDown() is also called if an exception occurred in one of the tests. If the problem is caused by some security or persistence related part of Flow, the error might be hard to track because their specialized tearDown() methods might cause fatal errors. In those cases just output the original exception message by adding an echo($this->statusMessage) as the first line of this method.
public tearDown ( ) : void
return void

tearDownSecurity() protected method

Resets security test requirements
protected tearDownSecurity ( ) : void
return void

Property Details

$authenticationManager protected property

protected AuthenticationManagerInterface,Neos\Flow\Security\Authentication $authenticationManager
return Neos\Flow\Security\Authentication\AuthenticationManagerInterface

$bootstrap protected static property

protected static Bootstrap,Neos\Flow\Core $bootstrap
return Neos\Flow\Core\Bootstrap

$browser protected property

Contains a virtual, preinitialized browser
protected Browser,Neos\Flow\Http\Client $browser
return Neos\Flow\Http\Client\Browser

$objectManager protected property

A functional instance of the Object Manager, for use in concrete test cases.
protected ObjectManagerInterface,Neos\Flow\ObjectManagement $objectManager
return Neos\Flow\ObjectManagement\ObjectManagerInterface

$persistenceManager protected property

protected PersistenceManagerInterface,Neos\Flow\Persistence $persistenceManager
return Neos\Flow\Persistence\PersistenceManagerInterface

$policyService protected property

protected PolicyService,Neos\Flow\Security\Policy $policyService
return Neos\Flow\Security\Policy\PolicyService

$privilegeManager protected property

protected PrivilegeManagerInterface,Neos\Flow\Security\Authorization $privilegeManager
return Neos\Flow\Security\Authorization\PrivilegeManagerInterface

$router protected property

Contains the router instance used in the browser's request engine
protected Router,Neos\Flow\Mvc\Routing $router
return Neos\Flow\Mvc\Routing\Router

$securityContext protected property

protected Context,Neos\Flow\Security $securityContext
return Neos\Flow\Security\Context

$testablePersistenceEnabled protected static property

If enabled, this test case will automatically run the compile() method on the Persistence Manager before running a test.
protected static bool $testablePersistenceEnabled
return boolean

$testableSecurityEnabled protected property

Note: this will implicitly enable testable HTTP as well.
protected bool $testableSecurityEnabled
return boolean

$testingProvider protected property

protected TestingProvider,Neos\Flow\Security\Authentication\Provider $testingProvider
return Neos\Flow\Security\Authentication\Provider\TestingProvider