diff --git a/core/modules/simpletest/tests/src/Unit/TestBaseTest.php b/core/modules/simpletest/tests/src/Unit/TestBaseTest.php index a67c84b..1a7a695 100644 --- a/core/modules/simpletest/tests/src/Unit/TestBaseTest.php +++ b/core/modules/simpletest/tests/src/Unit/TestBaseTest.php @@ -279,70 +279,94 @@ public function testAssertNotNull($expected, $value) { } /** - * Data provider for testAssertEqual(). + * Data provider for tests of equality assertions. + * + * Used by testAssertIdentical(), testAssertEqual(), testAssertNotIdentical(), + * and testAssertNotEqual(). + * + * @return + * Array of test data. + * - Expected assertion value for identical comparison. + * - Expected assertion value for equal comparison. + * - First value to compare. + * - Second value to compare. */ - public function providerAssertEqual() { - return array( - array(TRUE, 0, 0), - array(FALSE, 'foof', 'yay'), - ); + public function providerEqualityAssertions() { + return [ + // Integers and floats. + [TRUE, TRUE, 0, 0], + [FALSE, TRUE, 0, 0.0], + [FALSE, TRUE, '0', 0], + [FALSE, TRUE, '0.0', 0.0], + [FALSE, FALSE, 23, 77], + [TRUE, TRUE, 23.0, 23.0], + // Strings. + [FALSE, FALSE, 'foof', 'yay'], + [TRUE, TRUE, 'yay', 'yay'], + // Bools with type conversion. + [TRUE, TRUE, TRUE, TRUE], + [TRUE, TRUE, FALSE, FALSE], + [FALSE, TRUE, NULL, FALSE], + [FALSE, TRUE, 'TRUE', TRUE], + [FALSE, FALSE, 'FALSE', FALSE], + [FALSE, TRUE, 0, FALSE], + [FALSE, TRUE, 1, TRUE], + [FALSE, TRUE, -1, TRUE], + [FALSE, TRUE, '1', TRUE], + [FALSE, TRUE, '1.3', TRUE], + // Null. + [FALSE, FALSE, 'NULL', NULL], + [TRUE, TRUE, NULL, NULL], + // Null against unset value. + [TRUE, TRUE, $x, NULL], + ]; } /** - * @covers ::assertEqual - * @dataProvider providerAssertEqual + * @covers ::assertIdentical + * @dataProvider providerEqualityAssertions */ - public function testAssertEqual($expected, $first, $second) { + public function testAssertIdentical($expected_identical, $expected_equal, $first, $second) { $test_base = $this->getTestBaseForAssertionTests('test_id'); $this->assertEquals( - $expected, - $this->invokeProtectedMethod($test_base, 'assertEqual', array($first, $second)) + $expected_identical, + $this->invokeProtectedMethod($test_base, 'assertIdentical', array($first, $second)) ); } /** - * @covers ::assertNotEqual - * @dataProvider providerAssertEqual + * @covers ::assertNotIdentical + * @dataProvider providerAssertIdentical */ - public function testAssertNotEqual($expected, $first, $second) { + public function testAssertNotIdentical($expected_identical, $expected_equal, $first, $second) { $test_base = $this->getTestBaseForAssertionTests('test_id'); $this->assertEquals( - (!$expected), - $this->invokeProtectedMethod($test_base, 'assertNotEqual', array($first, $second)) - ); - } - - /** - * Data provider for testAssertIdentical and testAssertNotIdentical(). - */ - public function providerAssertIdentical() { - return array( - array(TRUE, 0, 0), - array(FALSE, 'foof', 'yay'), + (!$expected_identical), + $this->invokeProtectedMethod($test_base, 'assertNotIdentical', array($first, $second)) ); } /** - * @covers ::assertIdentical - * @dataProvider providerAssertIdentical + * @covers ::assertEqual + * @dataProvider providerEqualityAssertions */ - public function testAssertIdentical($expected, $first, $second) { + public function testAssertEqual($expected_identical, $expected_equal, $first, $second) { $test_base = $this->getTestBaseForAssertionTests('test_id'); $this->assertEquals( - $expected, - $this->invokeProtectedMethod($test_base, 'assertIdentical', array($first, $second)) + $expected_equal, + $this->invokeProtectedMethod($test_base, 'assertEqual', array($first, $second)) ); } /** - * @covers ::assertNotIdentical - * @dataProvider providerAssertIdentical + * @covers ::assertNotEqual + * @dataProvider providerEqualityAssertions */ - public function testAssertNotIdentical($expected, $first, $second) { + public function testAssertNotEqual($expected_identical, $expected_equal, $first, $second) { $test_base = $this->getTestBaseForAssertionTests('test_id'); $this->assertEquals( - (!$expected), - $this->invokeProtectedMethod($test_base, 'assertNotIdentical', array($first, $second)) + (!$expected_equal), + $this->invokeProtectedMethod($test_base, 'assertNotEqual', array($first, $second)) ); }