1<?php 2/* 3 * This file is part of PHPUnit. 4 * 5 * (c) Sebastian Bergmann <sebastian@phpunit.de> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11class Framework_Constraint_IsJsonTest extends PHPUnit_Framework_TestCase 12{ 13 /** 14 * @dataProvider evaluateDataprovider 15 */ 16 public function testEvaluate($expected, $jsonOther) 17 { 18 $constraint = new PHPUnit_Framework_Constraint_IsJson(); 19 $this->assertEquals($expected, $constraint->evaluate($jsonOther, '', true)); 20 } 21 22 public static function evaluateDataprovider() 23 { 24 return [ 25 'valid JSON' => [true, '{}'], 26 'empty string should be treated as invalid JSON' => [false, ''], 27 ]; 28 } 29} 30