diff --git a/core/tests/Drupal/Tests/Component/Utility/CryptTest.php b/core/tests/Drupal/Tests/Component/Utility/CryptTest.php index 6553462..ee0d602 100644 --- a/core/tests/Drupal/Tests/Component/Utility/CryptTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/CryptTest.php @@ -130,21 +130,27 @@ public function providerTestHmacBase64Invalid() { array(new \stdClass(), new \stdClass()), array(new \stdClass(), 'string'), array(new \stdClass(), 1), + array(new \stdClass(), 0), array(NULL, new \stdClass()), array('string', new \stdClass()), array(1, new \stdClass()), + array(0, new \stdClass()), array(array(), array()), array(array(), NULL), array(array(), 'string'), array(array(), 1), + array(array(), 0), array(NULL, array()), array(1, array()), + array(0, array()), array('string', array()), array(array(), NULL), array(NULL, NULL), array(NULL, 'string'), array(NULL, 1), + array(NULL, 0), array(1, NULL), + array(0, NULL), array('string', NULL), ); } diff --git a/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php b/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php index 30a915b..3a6d75c 100644 --- a/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php @@ -99,19 +99,51 @@ public function testValidate() { * (optional) An additional value to base the token on. * * @dataProvider providerTestValidateParameterTypes + */ + public function testValidateParameterTypes($token, $value) { + // The following check might throw PHP fatals and notices, so we disable + // error assertions. + set_error_handler(function () {return TRUE;}); + $this->assertFalse($this->generator->validate($token, $value)); + restore_error_handler(); + } + + /** + * Provides data for testValidateParameterTypes. + * + * @return array + * An array of data used by the test. + */ + public function providerTestValidateParameterTypes() { + return array( + array(array(), ''), + array(TRUE, 'foo'), + array(0, 'foo'), + ); + } + + /** + * Tests CsrfTokenGenerator::validate() with invalid parameter types. + * + * @param mixed $token + * The token to be validated. + * @param mixed $value + * (optional) An additional value to base the token on. + * + * @dataProvider providerTestInvalidParameterTypes * @expectedException InvalidArgumentException */ - public function testValidateParameterTypes($token, $value = '') { + public function testInvalidParameterTypes($token, $value = '') { $this->generator->validate($token, $value); } /** - * Provides data for the validate test. + * Provides data for testInvalidParameterTypes. * * @return array * An array of data used by the test. */ - public function providerTestValidateParameterTypes() { + public function providerTestInvalidParameterTypes() { return array( array(NULL, new \stdClass()), array(0, array()),