View source
<?php
namespace Drupal\xautoload\Tests\DrupalBootTest;
use Drupal\xautoload\Tests\VirtualDrupal\DrupalEnvironment;
use Drupal\xautoload\Tests\Example\ExampleModules;
use Drupal\xautoload\Tests\Filesystem\StreamWrapper;
use Drupal\xautoload\Tests\Util\CallLog;
use Drupal\xautoload\Tests\Util\StaticCallLog;
require_once dirname(dirname(__DIR__)) . '/bootstrap.php';
class DrupalBootTest extends AbstractDrupalBootTest {
private function initialModulesVariations($install) {
$variations = array();
$state = $install ? NULL : FALSE;
$variation = array(
'system' => TRUE,
);
$variation += array_fill_keys(array_keys($this->exampleModules
->getExampleClasses()), $state);
$variations[] = $variation;
foreach (array(
'xautoload',
) as $module) {
$variations = $this
->providerArrayKeyVariations($variations, $module, array(
TRUE,
FALSE,
NULL,
));
}
return $variations;
}
public function providerModuleEnable() {
$this
->initOnce();
$variations = array();
foreach (array(
TRUE,
FALSE,
) as $install) {
$expectedCalls = array();
$enabledModulesSoFar = array();
foreach ($this->exampleModules
->getExampleClasses() as $module => $classes) {
$enabledModulesSoFar[] = $module;
if ($install) {
$expectedCalls[] = array(
'function' => $module . '_schema',
'args' => array(),
);
$expectedCalls[] = array(
'function' => $module . '_install',
'args' => array(),
);
foreach ($enabledModulesSoFar as $module) {
$expectedCalls[] = array(
'function' => $module . '_watchdog',
'args' => array(),
);
}
}
$expectedCalls[] = array(
'function' => $module . '_enable',
'args' => array(),
);
foreach ($enabledModulesSoFar as $module) {
$expectedCalls[] = array(
'function' => $module . '_watchdog',
'args' => array(),
);
}
}
foreach ($this
->initialModulesVariations($install) as $moduleStates) {
$variationExpectedCalls = $expectedCalls;
foreach (array_keys($this->exampleModules
->getExampleClasses()) as $module) {
$variationExpectedCalls[] = array(
'function' => $module . '_modules_enabled',
'args' => array(
'(array)',
),
);
}
$variations[] = array(
$moduleStates,
$variationExpectedCalls,
);
}
}
return $variations;
}
function initOnce() {
if (isset($this->exampleDrupal)) {
return;
}
$this->exampleModules = new ExampleModules();
$this->exampleDrupal = new DrupalEnvironment($this->exampleModules);
$this->exampleDrupal
->setStaticInstance();
}
protected function prepare() {
$this
->initOnce();
$filesystem = StreamWrapper::register('test');
foreach ($this->exampleModules
->discoverModuleFilenames('module') as $name => $filename) {
$this->exampleDrupal
->getSystemTable()
->addModuleWithFilename($name, $filename);
}
$this->exampleDrupal
->getSystemTable()
->moduleSetEnabled('system');
$this->exampleDrupal
->initBootstrapStatus();
xautoload()
->getServiceContainer()
->set('system', $this->exampleDrupal
->getMockDrupalSystem());
$this->callLog = new CallLog();
StaticCallLog::setCallLog($this->callLog);
}
protected function getExpectedCallsForNormalRequest() {
$expectedCalls = array();
foreach ($this->exampleModules
->getExampleClasses() as $module => $classes) {
$expectedCalls[] = array(
'function' => $module . '_init',
'args' => array(),
);
}
return $expectedCalls;
}
}