mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
NEW: Refactor test bootstrap to be more modular.
The test bootstrap is broken into units that can be combined for different test situations: - phpunit - behat - serve
This commit is contained in:
parent
d946a3b240
commit
bf9939e32c
7
tests/behat/serve-bootstrap.php
Normal file
7
tests/behat/serve-bootstrap.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../bootstrap/init.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/init.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/environment.php';
|
||||
require __DIR__ . '/../bootstrap/mysite.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/mysite.php';
|
10
tests/bootstrap.php
Normal file
10
tests/bootstrap.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/bootstrap/init.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/init.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/cli.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/environment.php';
|
||||
require __DIR__ . '/bootstrap/mysite.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/mysite.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/phpunit.php';
|
||||
|
12
tests/bootstrap/fixtures/Page.php.fixture
Normal file
12
tests/bootstrap/fixtures/Page.php.fixture
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\CMS\Controllers\ContentController;
|
||||
|
||||
class Page extends SiteTree
|
||||
{
|
||||
}
|
||||
|
||||
class Page_Controller extends ContentController
|
||||
{
|
||||
}
|
0
tests/bootstrap/fixtures/_manifest_exclude
Normal file
0
tests/bootstrap/fixtures/_manifest_exclude
Normal file
12
tests/bootstrap/init.php
Normal file
12
tests/bootstrap/init.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
if(!defined('FRAMEWORK_PATH')) {
|
||||
echo "FRAMEWORK_PATH hasn't been defined. This probably means that framework/Core/Constants.php hasn't been " .
|
||||
"included by Composer's autoloader.\n" .
|
||||
"Make sure the you are running your tests via vendor/bin/phpunit and your autoloader is up to date.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (empty($_SERVER['HTTP_HOST'])) {
|
||||
$_SERVER['HTTP_HOST'] = 'localhost';
|
||||
}
|
14
tests/bootstrap/mysite.php
Normal file
14
tests/bootstrap/mysite.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
// Mock mysite if not installed with silverstripe/installer
|
||||
if (defined('BASE_PATH')) {
|
||||
$projectPath = BASE_PATH . '/mysite';
|
||||
} else {
|
||||
$projectPath = getcwd() . '/mysite';
|
||||
}
|
||||
if (!is_dir($projectPath)) {
|
||||
mkdir($projectPath, 02775);
|
||||
mkdir($projectPath.'/code', 02775);
|
||||
mkdir($projectPath.'/_config', 02775);
|
||||
copy(__DIR__.'/fixtures/Page.php.fixture', $projectPath . '/code/Page.php');
|
||||
}
|
Loading…
Reference in New Issue
Block a user