View source
<?php
namespace Drupal\xautoload\Tests\DrupalBootTest;
use Drupal\xautoload\Tests\Example\HookTestExampleModules;
use Drupal\xautoload\Tests\VirtualDrupal\DrupalEnvironment;
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 DrupalBootHookTest extends AbstractDrupalBootTest {
public function providerModuleEnable() {
$hookXautoloadEarly = FALSE;
$hookXautoloadLate = TRUE;
$initialModuleVariations = array(
array(
'system' => TRUE,
),
);
foreach (array(
'xautoload' => array(
FALSE,
TRUE,
),
'libraries' => array(
FALSE,
TRUE,
),
'testmod' => array(
FALSE,
NULL,
),
) as $module => $states) {
$initialModuleVariations = $this
->providerArrayKeyVariations($initialModuleVariations, $module, $states);
}
$variations = array();
foreach ($initialModuleVariations as $initialModuleVariation) {
$expectedCalls = array();
if ($hookXautoloadEarly) {
$expectedCalls[] = array(
'function' => 'testmod_xautoload',
'args' => array(
'(xautoload_InjectedAPI_hookXautoload)',
dirname(dirname(__DIR__)) . '/fixtures/.modules/testmod',
),
);
}
if (NULL === $initialModuleVariation['testmod']) {
$expectedCalls[] = array(
'function' => 'testmod_schema',
'args' => array(),
);
$expectedCalls[] = array(
'function' => 'testmod_install',
'args' => array(),
);
$expectedCalls[] = array(
'function' => 'testmod_watchdog',
'args' => array(),
);
}
$expectedCalls[] = array(
'function' => 'testmod_enable',
'args' => array(),
);
$expectedCalls[] = array(
'function' => 'testmod_watchdog',
'args' => array(),
);
if ($hookXautoloadLate) {
$expectedCalls[] = array(
'function' => 'testmod_xautoload',
'args' => array(
'(xautoload_InjectedAPI_hookXautoload)',
dirname(dirname(__DIR__)) . '/fixtures/.modules/testmod',
),
);
}
$expectedCalls[] = array(
'function' => 'testmod_modules_enabled',
'args' => array(
'(array)',
),
);
$expectedCalls[] = array(
'function' => 'testmod_libraries_info',
'args' => array(),
);
$expectedCalls[] = array(
'function' => '_testmod_libraries_testlib_xautoload',
'args' => array(
'(xautoload_InjectedAPI_hookXautoload)',
dirname(dirname(__DIR__)) . '/fixtures/.libraries/testlib',
),
);
$variations[] = array(
$initialModuleVariation,
$expectedCalls,
);
}
return $variations;
}
function initOnce() {
if (isset($this->exampleDrupal)) {
return;
}
$this->exampleModules = new HookTestExampleModules();
$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(
array(
'function' => 'testmod_xautoload',
'args' => array(
'(xautoload_InjectedAPI_hookXautoload)',
dirname(dirname(__DIR__)) . '/fixtures/.modules/testmod',
),
),
array(
'function' => 'testmod_init',
'args' => array(),
),
array(
'function' => 'testmod_libraries_info',
'args' => array(),
),
array(
'function' => '_testmod_libraries_testlib_xautoload',
'args' => array(
'(xautoload_InjectedAPI_hookXautoload)',
dirname(dirname(__DIR__)) . '/fixtures/.libraries/testlib',
),
),
);
return $expectedCalls;
}
}