Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
JsonValidatorTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class JsonValidatorTest extends \PHPUnit\Framework\TestCase
11 {
15  private $jsonValidator;
16 
17  protected function setUp()
18  {
19  $this->jsonValidator = new JsonValidator();
20  }
21 
27  public function testIsValid($value, $expected)
28  {
29  $this->assertEquals(
30  $expected,
31  $this->jsonValidator->isValid($value)
32  );
33  }
34 
38  public function isValidDataProvider()
39  {
40  return [
41  ['""', true],
42  ['"string"', true],
43  ['null', true],
44  ['false', true],
45  ['{"a":"b","d":123}', true],
46  ['123', true],
47  ['10.56', true],
48  [123, true],
49  [10.56, true],
50  ['{}', true],
51  ['"', false],
52  ['"string', false],
53  [null, false],
54  [false, false],
55  ['{"a', false],
56  ['{', false],
57  ['', false]
58  ];
59  }
60 }
$value
Definition: gender.phtml:16