Issue #2096595 by neclimdul, damiankloip, tim.plunkett, Mile23, ParisLiakos: Make all PHPUnit tests pass with --strict.

8.0.x
Alex Pott 2013-10-03 22:41:41 +01:00
parent cf8c025b33
commit 1402c66318
7 changed files with 22 additions and 11 deletions

View File

@ -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>

View File

@ -57,6 +57,9 @@ class MTimeProtectedFileStorageTest extends PhpStorageTestBase {
*
* 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');

View File

@ -153,7 +153,7 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
*
* @see testRender
*/
function testRenderProvider() {
function providerTestRender() {
// Default for 'browsers' key in CSS asset.
$browsers_default = array('IE' => TRUE, '!IE' => TRUE);
@ -538,7 +538,7 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
/**
* Tests CSS asset rendering.
*
* @dataProvider testRenderProvider
* @dataProvider providerTestRender
*/
function testRender(array $css_assets, array $render_elements) {
$this->state->expects($this->once())

View File

@ -86,7 +86,7 @@ class CssOptimizerUnitTest extends UnitTestCase {
/**
* 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 @@ class CssOptimizerUnitTest extends UnitTestCase {
/**
* 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.');

View File

@ -39,10 +39,11 @@ class EmptyStatementTest extends UnitTestCase {
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.');
}
/**

View File

@ -13,6 +13,7 @@ if (!defined('DRUPAL_ROOT')) {
use Drupal\Core\Extension\ModuleHandler;
use Drupal\Tests\UnitTestCase;
use PHPUnit_Framework_Error_Notice;
/**
* Tests the ModuleHandler class.
@ -34,9 +35,12 @@ class ModuleHandlerUnitTest extends UnitTestCase {
$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'));
}
}

View File

@ -52,6 +52,9 @@ class LockBackendAbstractTest extends UnitTestCase {
/**
* 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())