X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fphpunit%2Fphpunit%2Ftests%2FFramework%2FConstraint%2FJsonMatches%2FErrorMessageProviderTest.php;fp=vendor%2Fphpunit%2Fphpunit%2Ftests%2FFramework%2FConstraint%2FJsonMatches%2FErrorMessageProviderTest.php;h=85290262946dde6f5abc23a2c94ac54922720f24;hb=eba34333e3c89f208d2f72fa91351ad019a71583;hp=0000000000000000000000000000000000000000;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/phpunit/phpunit/tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php b/vendor/phpunit/phpunit/tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php new file mode 100644 index 000000000..852902629 --- /dev/null +++ b/vendor/phpunit/phpunit/tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * @since File available since Release 3.7.0 + */ +class Framework_Constraint_JsonMatches_ErrorMessageProviderTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider translateTypeToPrefixDataprovider + * @covers PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::translateTypeToPrefix + */ + public function testTranslateTypeToPrefix($expected, $type) + { + $this->assertEquals( + $expected, + PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::translateTypeToPrefix($type) + ); + } + + /** + * @dataProvider determineJsonErrorDataprovider + * @covers PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError + */ + public function testDetermineJsonError($expected, $error, $prefix) + { + $this->assertEquals( + $expected, + PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError( + $error, + $prefix + ) + ); + } + + public static function determineJsonErrorDataprovider() + { + return array( + 'JSON_ERROR_NONE' => array( + null, 'json_error_none', '' + ), + 'JSON_ERROR_DEPTH' => array( + 'Maximum stack depth exceeded', JSON_ERROR_DEPTH, '' + ), + 'prefixed JSON_ERROR_DEPTH' => array( + 'TUX: Maximum stack depth exceeded', JSON_ERROR_DEPTH, 'TUX: ' + ), + 'JSON_ERROR_STATE_MISMatch' => array( + 'Underflow or the modes mismatch', JSON_ERROR_STATE_MISMATCH, '' + ), + 'JSON_ERROR_CTRL_CHAR' => array( + 'Unexpected control character found', JSON_ERROR_CTRL_CHAR, '' + ), + 'JSON_ERROR_SYNTAX' => array( + 'Syntax error, malformed JSON', JSON_ERROR_SYNTAX, '' + ), + 'JSON_ERROR_UTF8`' => array( + 'Malformed UTF-8 characters, possibly incorrectly encoded', + JSON_ERROR_UTF8, + '' + ), + 'Invalid error indicator' => array( + 'Unknown error', 55, '' + ), + ); + } + + public static function translateTypeToPrefixDataprovider() + { + return array( + 'expected' => array('Expected value JSON decode error - ', 'expected'), + 'actual' => array('Actual value JSON decode error - ', 'actual'), + 'default' => array('', ''), + ); + } +}