From 1402c66318a801eeeb2c4f1fc7fc73aded477fed Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Thu, 3 Oct 2013 22:41:41 +0100 Subject: [PATCH] Issue #2096595 by neclimdul, damiankloip, tim.plunkett, Mile23, ParisLiakos: Make all PHPUnit tests pass with --strict. --- core/phpunit.xml.dist | 2 +- .../PhpStorage/MTimeProtectedFileStorageTest.php | 3 +++ .../Core/Asset/CssCollectionRendererUnitTest.php | 4 ++-- .../Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php | 4 ++-- .../Tests/Core/Database/EmptyStatementTest.php | 5 +++-- .../Tests/Core/Extension/ModuleHandlerUnitTest.php | 12 ++++++++---- .../Tests/Core/Lock/LockBackendAbstractTest.php | 3 +++ 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist index 6ca7e89f8031..f7c97fc873e7 100644 --- a/core/phpunit.xml.dist +++ b/core/phpunit.xml.dist @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit bootstrap="tests/bootstrap.php" colors="true"> +<phpunit bootstrap="tests/bootstrap.php" colors="true" strict="true"> <testsuites> <testsuite name="Drupal Unit Test Suite"> <directory>./tests/*</directory> diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php index 3cd1e6246918..55d01c8ee094 100644 --- a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php +++ b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php @@ -57,6 +57,9 @@ function testCRUD() { * * We test two attacks: first changes the file mtime, then the directory * mtime too. + * + * We need to delay over 1 second for mtime test. + * @medium */ function testSecurity() { $php = $this->storageFactory->get('simpletest'); diff --git a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php index d8e3a3294753..bfbe65c26354 100644 --- a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php @@ -153,7 +153,7 @@ function setUp() { * * @see testRender */ - function testRenderProvider() { + function providerTestRender() { // Default for 'browsers' key in CSS asset. $browsers_default = array('IE' => TRUE, '!IE' => TRUE); @@ -538,7 +538,7 @@ function testRenderProvider() { /** * Tests CSS asset rendering. * - * @dataProvider testRenderProvider + * @dataProvider providerTestRender */ function testRender(array $css_assets, array $render_elements) { $this->state->expects($this->once()) diff --git a/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php index a077ad536539..2fbf61952de6 100644 --- a/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php @@ -86,7 +86,7 @@ function setUp() { /** * Provides data for the CSS asset optimizing test. */ - function testOptimizeProvider() { + function providerTestOptimize() { $path = dirname(__FILE__) . '/css_test_files/'; return array( // File. Tests: @@ -194,7 +194,7 @@ function testOptimizeProvider() { /** * Tests optimizing a CSS asset group containing 'type' => 'file'. * - * @dataProvider testOptimizeProvider + * @dataProvider providerTestOptimize */ function testOptimize($css_asset, $expected) { $this->assertEquals($expected, $this->optimizer->optimize($css_asset), 'Group of file CSS assets optimized correctly.'); diff --git a/core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php b/core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php index 9bf2c8071e39..6877a9ce35bf 100644 --- a/core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php +++ b/core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php @@ -39,10 +39,11 @@ function testEmpty() { function testEmptyIteration() { $result = new StatementEmpty(); + $count = 0; foreach ($result as $record) { - $this->fail('Iterating empty result set should not iterate.'); - return; + $count++; } + $this->assertSame(0, $count, 'Iterating empty result set should not iterate.'); } /** diff --git a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerUnitTest.php b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerUnitTest.php index 45ad0d26369f..49ab1f83c9b8 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerUnitTest.php @@ -13,6 +13,7 @@ use Drupal\Core\Extension\ModuleHandler; use Drupal\Tests\UnitTestCase; +use PHPUnit_Framework_Error_Notice; /** * Tests the ModuleHandler class. @@ -34,9 +35,12 @@ function setUp() { $this->moduleHandler = new ModuleHandler; } - function testloadInclude() { - // Make sure that load include does not throw notices on nonexisiting - // modules. - $this->moduleHandler->loadInclude('foo', 'inc'); + /** + * Tests loading of an include from a nonexistent module. + */ + public function testLoadInclude() { + // Attepmting to load a file from a non-existent module should return FALSE. + $this->assertFalse($this->moduleHandler->loadInclude('foo', 'inc')); } + } diff --git a/core/tests/Drupal/Tests/Core/Lock/LockBackendAbstractTest.php b/core/tests/Drupal/Tests/Core/Lock/LockBackendAbstractTest.php index 933f8b5fbfaa..2ce4ef7fe018 100644 --- a/core/tests/Drupal/Tests/Core/Lock/LockBackendAbstractTest.php +++ b/core/tests/Drupal/Tests/Core/Lock/LockBackendAbstractTest.php @@ -52,6 +52,9 @@ public function testWaitFalse() { /** * Tests the wait() method when lockMayBeAvailable() returns FALSE. + * + * Waiting could take 1 second so we need to extend the possible runtime. + * @medium */ public function testWaitTrue() { $this->lock->expects($this->any()) -- GitLab