group | title | redirect_to | status |
---|---|---|---|
testing |
Application Area Annotation in the Integration Testing Framework |
migrated |
Configure a test environment in scope of the particular application area with the @magentoAppArea
annotation.
/**
* @magentoAppArea <area code>
*/
- Test annotation
- Test case annotation
- Default application area, which is
global
A test case annotation enables the specified application area for all tests in the test case.
{:.bs-callout-info} Test annotations override test case annotations.
Example:
/**
* @magentoAppArea adminhtml
*/
namespace Vendor\Module;
class ClassToTest extends \PHPUnit\Framework\TestCase
{
public function testOne()
{
//...
}
/**
* @magentoAppArea frontend
*/
public function testTwo()
{
//...
}
public function testThree()
{
//...
}
}
testOne()
and testThree()
are set to run in scope of the adminhtml
application area, whereas testTwo()
is set to run in scope of the frontend
area.
A test annotation is used to configure the environment in scope of the specified application area for the test. Magento is reinitialized in the corresponding scope each time you specify a different area.
Example:
namespace \Vendor\Module;
class ClassToTest extends \PHPUnit\Framework\TestCase
{
// executes the test in scope of the global area
public function testOne()
{
//...
}
// reinitializes the application and executes the test in scope of the frontend area
/**
* @magentoAppArea frontend
*/
public function testTwo()
{
//...
}
// reinitializes the application and executes the test in scope of the adminhtml area
/**
* @magentoAppArea adminhtml
*/
public function testThree()
{
//...
}
// reinitializes the application and executes the test in scope of the global area
public function testFour()
{
//...
}
// executes in scope of the global area
public function testFive()
{
//...
}
}