Wouter Wolters wrote:
How do you run your functional tests? What is the exact command?
Here are some excerpts from the test suite for the checkout. Please notice that this uses already an extended API:
/**
* Test case for checkout with a filled cart
*
* [...]
*/
class CheckoutWithFilledCartTest extends FunctionalTestCase {
/**
* @var array
*/
protected $coreExtensionsToLoad = array(
'extbase',
'fluid'
);
/**
* @var array
*/
protected $testExtensionsToLoad = array(
'typo3conf/ext/events'
);
/**
* @var array
*/
protected $configurationToUseInTestInstance = array(
'MAIL' => array(
'transport' => 'mbox',
'transport_mbox_file' => VENDOR_EVENTS_CONTROLLER_CHECKOUT_WITH_FILLED_CART_TEST_INSTANCE_PATH . '/typo3temp/mail.box'
)
);
// [...]
protected function getMail() {
return file_get_contents($this->configurationToUseInTestInstance['MAIL']['transport_mbox_file']);
}
/**
* Sets up this test suite
*/
protected function setUp() {
parent::setUp();
$this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
$this->importDataSet(ORIGINAL_ROOT . 'typo3conf/ext/events/Tests/Functional/Fixtures/events.xml');
// [...]
$this->setUpFrontendRootPage(1, array(
'typo3conf/ext/events/Configuration/TypoScript/setup.txt',
'typo3conf/ext/events/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'
), array(
'typo3conf/ext/events/Configuration/TypoScript/constants.txt'
));
// [...]
$this->frontendResponse = $this->getFrontendResponse(1, 0, 0, 0, true, 0, array(
'tx_events_cart' => array(
'action' => 'add',
'qty' => '2',
'ticket' => '1'
)
));
}
/**
* Tears down this test suite
*/
protected function tearDown() {
unlink($this->configurationToUseInTestInstance['MAIL']['transport_mbox_file']);
}
// [...]
/**
* @test
*/
public function supportsTameOrder() {
// [...]
// fill out order step
$response = $this->getFrontendResponse(1, 0, 0, 0, true, 0, array(
'tx_events_checkout' => array(
'action' => 'forward',
'termsAndConditions' => 1
)
), $this->frontendResponse->getCookies());
$section = $response->getResponseContent()->getSection('Checkout');
$mail = $this->getMail();
// [...]
$this->assertRegExp('/^Subject: Order #1/m', $mail);
$this->assertRegExp('/^From: noreply@domain.tld/m', $mail);
$this->assertRegExp('/^To: order@domain.tld/m', $mail);
// [...]
}
// [...]
}
I run this test just with ../vendor/phpunit/phpunit/phpunit -c typo3conf/ext/events/Build/FunctionalTests.xml
. The FunctionalTests.xml
looks like this:
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="../../../../typo3/sysext/core/Build/FunctionalTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="true">
<testsuites>
<testsuite name="EXT:events">
<directory>../Tests/Functional/</directory>
</testsuite>
</testsuites>
</phpunit>