Loading core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php 0 → 100644 +35 −0 Changes for core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php: 35 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\Tests\Core\Test; use Drupal\Tests\UnitTestCase; use Symfony\Component\Process\Process; /** * @group TestSuites * @group Test */ class PhpUnitCliTest extends UnitTestCase { /** * Ensure that the test suites are able to discover tests without incident. */ public function testPhpUnitListTests() { // Generate the list of tests for all the tests the suites can discover. // The goal here is to successfully generate the list, without any // duplicate namespace errors or so forth. This keeps us from committing // tests which don't break under run-tests.sh, but do break under the // phpunit test runner tool. $process = new Process('vendor/bin/phpunit --configuration core --verbose --list-tests'); $process->setWorkingDirectory($this->root) ->setTimeout(300) ->setIdleTimeout(300); $process->run(); $this->assertEquals(0, $process->getExitCode(), 'COMMAND: ' . $process->getCommandLine() . "\n" . 'OUTPUT: ' . $process->getOutput() . "\n" . 'ERROR: ' . $process->getErrorOutput() . "\n" ); } } core/tests/Drupal/Tests/Core/Theme/RegistryLegacyTest.php +11 −42 Changes for core/tests/Drupal/Tests/Core/Theme/RegistryLegacyTest.php: 11 added lines, 42 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains \Drupal\Tests\Core\Theme\RegistryLegacyTest. */ namespace Drupal\Tests\Core\Theme; use Drupal\Core\Theme\ActiveTheme; Loading @@ -21,9 +16,9 @@ class RegistryLegacyTest extends UnitTestCase { /** * The tested theme registry. * The mocked theme registry. * * @var \Drupal\Tests\Core\Theme\TestRegistry * @var \Drupal\Core\Theme\Registry|PHPUnit\Framework\MockObject\MockObject */ protected $registry; Loading Loading @@ -69,13 +64,6 @@ class RegistryLegacyTest extends UnitTestCase { */ protected $themeManager; /** * The list of functions that get_defined_functions() should provide. * * @var array */ public static $functions = []; /** * {@inheritdoc} */ Loading @@ -92,14 +80,6 @@ protected function setUp() { $this->setupTheme(); } /** * {@inheritdoc} */ protected function tearDown() { parent::tearDown(); static::$functions = []; } /** * Tests getting legacy theme function registry data defined by a module. * Loading Loading @@ -152,29 +132,18 @@ public function testGetLegacyThemeFunctionRegistryForModule() { } protected function setupTheme() { $this->registry = new TestRegistry($this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization); $this->registry->setThemeManager($this->themeManager); } } class TestRegistry extends Registry { protected function getPath($module) { $this->registry = $this->getMockBuilder(Registry::class) ->setMethods(['getPath']) ->setConstructorArgs([$this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization]) ->getMock(); $this->registry->expects($this->any()) ->method('getPath') ->willReturnCallback(function ($module) { if ($module == 'theme_legacy_test') { return 'core/modules/system/tests/modules/theme_legacy_test'; } }); $this->registry->setThemeManager($this->themeManager); } } namespace Drupal\Core\Theme; use Drupal\Tests\Core\Theme\RegistryLegacyTest; /** * Overrides get_defined_functions() with a configurable mock. */ function get_defined_functions() { return RegistryLegacyTest::$functions ?: \get_defined_functions(); } core/tests/Drupal/Tests/Core/Theme/RegistryTest.php +12 −17 Changes for core/tests/Drupal/Tests/Core/Theme/RegistryTest.php: 12 added lines, 17 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains \Drupal\Tests\Core\Theme\RegistryTest. */ namespace Drupal\Tests\Core\Theme; use Drupal\Core\Theme\ActiveTheme; Loading @@ -18,9 +13,9 @@ class RegistryTest extends UnitTestCase { /** * The tested theme registry. * The mocked theme registry. * * @var \Drupal\Tests\Core\Theme\TestRegistry * @var \Drupal\Core\Theme\Registry|PHPUnit\Framework\MockObject\MockObject */ protected $registry; Loading Loading @@ -190,7 +185,7 @@ public function testPostProcessExtension($defined_functions, $hooks, $expected) ->method('getModuleList') ->willReturn([]); $class = new \ReflectionClass(TestRegistry::class); $class = new \ReflectionClass(Registry::class); $reflection_method = $class->getMethod('postProcessExtension'); $reflection_method->setAccessible(TRUE); $reflection_method->invokeArgs($this->registry, [&$hooks, $theme->reveal()]); Loading Loading @@ -476,18 +471,18 @@ public function providerTestPostProcessExtension() { } protected function setupTheme() { $this->registry = new TestRegistry($this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization); $this->registry->setThemeManager($this->themeManager); } } class TestRegistry extends Registry { protected function getPath($module) { $this->registry = $this->getMockBuilder(Registry::class) ->setMethods(['getPath']) ->setConstructorArgs([$this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization]) ->getMock(); $this->registry->expects($this->any()) ->method('getPath') ->willReturnCallback(function ($module) { if ($module == 'theme_test') { return 'core/modules/system/tests/modules/theme_test'; } }); $this->registry->setThemeManager($this->themeManager); } } Loading Loading
core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php 0 → 100644 +35 −0 Changes for core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php: 35 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\Tests\Core\Test; use Drupal\Tests\UnitTestCase; use Symfony\Component\Process\Process; /** * @group TestSuites * @group Test */ class PhpUnitCliTest extends UnitTestCase { /** * Ensure that the test suites are able to discover tests without incident. */ public function testPhpUnitListTests() { // Generate the list of tests for all the tests the suites can discover. // The goal here is to successfully generate the list, without any // duplicate namespace errors or so forth. This keeps us from committing // tests which don't break under run-tests.sh, but do break under the // phpunit test runner tool. $process = new Process('vendor/bin/phpunit --configuration core --verbose --list-tests'); $process->setWorkingDirectory($this->root) ->setTimeout(300) ->setIdleTimeout(300); $process->run(); $this->assertEquals(0, $process->getExitCode(), 'COMMAND: ' . $process->getCommandLine() . "\n" . 'OUTPUT: ' . $process->getOutput() . "\n" . 'ERROR: ' . $process->getErrorOutput() . "\n" ); } }
core/tests/Drupal/Tests/Core/Theme/RegistryLegacyTest.php +11 −42 Changes for core/tests/Drupal/Tests/Core/Theme/RegistryLegacyTest.php: 11 added lines, 42 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains \Drupal\Tests\Core\Theme\RegistryLegacyTest. */ namespace Drupal\Tests\Core\Theme; use Drupal\Core\Theme\ActiveTheme; Loading @@ -21,9 +16,9 @@ class RegistryLegacyTest extends UnitTestCase { /** * The tested theme registry. * The mocked theme registry. * * @var \Drupal\Tests\Core\Theme\TestRegistry * @var \Drupal\Core\Theme\Registry|PHPUnit\Framework\MockObject\MockObject */ protected $registry; Loading Loading @@ -69,13 +64,6 @@ class RegistryLegacyTest extends UnitTestCase { */ protected $themeManager; /** * The list of functions that get_defined_functions() should provide. * * @var array */ public static $functions = []; /** * {@inheritdoc} */ Loading @@ -92,14 +80,6 @@ protected function setUp() { $this->setupTheme(); } /** * {@inheritdoc} */ protected function tearDown() { parent::tearDown(); static::$functions = []; } /** * Tests getting legacy theme function registry data defined by a module. * Loading Loading @@ -152,29 +132,18 @@ public function testGetLegacyThemeFunctionRegistryForModule() { } protected function setupTheme() { $this->registry = new TestRegistry($this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization); $this->registry->setThemeManager($this->themeManager); } } class TestRegistry extends Registry { protected function getPath($module) { $this->registry = $this->getMockBuilder(Registry::class) ->setMethods(['getPath']) ->setConstructorArgs([$this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization]) ->getMock(); $this->registry->expects($this->any()) ->method('getPath') ->willReturnCallback(function ($module) { if ($module == 'theme_legacy_test') { return 'core/modules/system/tests/modules/theme_legacy_test'; } }); $this->registry->setThemeManager($this->themeManager); } } namespace Drupal\Core\Theme; use Drupal\Tests\Core\Theme\RegistryLegacyTest; /** * Overrides get_defined_functions() with a configurable mock. */ function get_defined_functions() { return RegistryLegacyTest::$functions ?: \get_defined_functions(); }
core/tests/Drupal/Tests/Core/Theme/RegistryTest.php +12 −17 Changes for core/tests/Drupal/Tests/Core/Theme/RegistryTest.php: 12 added lines, 17 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains \Drupal\Tests\Core\Theme\RegistryTest. */ namespace Drupal\Tests\Core\Theme; use Drupal\Core\Theme\ActiveTheme; Loading @@ -18,9 +13,9 @@ class RegistryTest extends UnitTestCase { /** * The tested theme registry. * The mocked theme registry. * * @var \Drupal\Tests\Core\Theme\TestRegistry * @var \Drupal\Core\Theme\Registry|PHPUnit\Framework\MockObject\MockObject */ protected $registry; Loading Loading @@ -190,7 +185,7 @@ public function testPostProcessExtension($defined_functions, $hooks, $expected) ->method('getModuleList') ->willReturn([]); $class = new \ReflectionClass(TestRegistry::class); $class = new \ReflectionClass(Registry::class); $reflection_method = $class->getMethod('postProcessExtension'); $reflection_method->setAccessible(TRUE); $reflection_method->invokeArgs($this->registry, [&$hooks, $theme->reveal()]); Loading Loading @@ -476,18 +471,18 @@ public function providerTestPostProcessExtension() { } protected function setupTheme() { $this->registry = new TestRegistry($this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization); $this->registry->setThemeManager($this->themeManager); } } class TestRegistry extends Registry { protected function getPath($module) { $this->registry = $this->getMockBuilder(Registry::class) ->setMethods(['getPath']) ->setConstructorArgs([$this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization]) ->getMock(); $this->registry->expects($this->any()) ->method('getPath') ->willReturnCallback(function ($module) { if ($module == 'theme_test') { return 'core/modules/system/tests/modules/theme_test'; } }); $this->registry->setThemeManager($this->themeManager); } } Loading