1313
1414class AssertTraitTest extends \PHPUnit_Framework_TestCase
1515{
16- private static function getSchema ($ filename )
17- {
18- return implode (DIRECTORY_SEPARATOR , [__DIR__ , 'schemas ' , $ filename ]);
19- }
20-
21- private static function getJson ($ filename )
22- {
23- return implode (DIRECTORY_SEPARATOR , [__DIR__ , 'json ' , $ filename ]);
24- }
25-
26- public function testAssertJsonSchema ()
16+ public function testAssertJsonMatchesSchema ()
2717 {
2818 $ content = json_decode ('{"foo":123} ' );
2919
30- AssertTraitImpl::assertJsonMatchesSchema (self :: getSchema ('test.schema.json ' ), $ content );
20+ AssertTraitImpl::assertJsonMatchesSchema (Utils:: getSchemaPath ('test.schema.json ' ), $ content );
3121 }
3222
3323 /**
3424 * @expectedException \PHPUnit_Framework_ExpectationFailedException
3525 */
36- public function testAssertJsonSchemaFail ()
26+ public function testAssertJsonMatchesSchemaFail ()
3727 {
3828 $ content = json_decode ('{"foo":"123"} ' );
3929
40- AssertTraitImpl::assertJsonMatchesSchema (self :: getSchema ('test.schema.json ' ), $ content );
30+ AssertTraitImpl::assertJsonMatchesSchema (Utils:: getSchemaPath ('test.schema.json ' ), $ content );
4131 }
4232
43- public function testAssertJsonSchemaFailMessage ()
33+ public function testAssertJsonMatchesSchemaFailMessage ()
4434 {
4535 $ content = json_decode ('{"foo":"123"} ' );
4636
4737 $ exception = null ;
4838
4939 try {
50- AssertTraitImpl::assertJsonMatchesSchema (self :: getSchema ('test.schema.json ' ), $ content );
40+ AssertTraitImpl::assertJsonMatchesSchema (Utils:: getSchemaPath ('test.schema.json ' ), $ content );
5141 } catch (\PHPUnit_Framework_ExpectationFailedException $ exception ) {
5242 self ::assertContains ('- Property: foo, Contraint: type, Message: String value found, but an integer is required ' , $ exception ->getMessage ());
5343 self ::assertContains ('- Response: {"foo":"123"} ' , $ exception ->getMessage ());
@@ -59,27 +49,27 @@ public function testAssertJsonSchemaFailMessage()
5949 /**
6050 * Tests if referenced schemas are loaded automatically.
6151 */
62- public function testAssertJsonSchemaWithRefs ()
52+ public function testAssertJsonMatchesSchemaWithRefs ()
6353 {
6454 $ content = json_decode ('{"code":123, "message":"Nothing works."} ' );
6555
66- AssertTraitImpl::assertJsonMatchesSchema (self :: getSchema ('error.schema.json ' ), $ content );
56+ AssertTraitImpl::assertJsonMatchesSchema (Utils:: getSchemaPath ('error.schema.json ' ), $ content );
6757 }
6858
6959 /**
7060 * @expectedException \PHPUnit_Framework_ExpectationFailedException
7161 */
72- public function testAssertJsonSchemaWithRefsFails ()
62+ public function testAssertJsonMatchesSchemaWithRefsFails ()
7363 {
7464 $ content = json_decode ('{"code":"123", "message":"Nothing works."} ' );
7565
76- AssertTraitImpl::assertJsonMatchesSchema (self :: getSchema ('error.schema.json ' ), $ content );
66+ AssertTraitImpl::assertJsonMatchesSchema (Utils:: getSchemaPath ('error.schema.json ' ), $ content );
7767 }
7868
7969 public function testAssertJsonMatchesSchemaString ()
8070 {
8171 $ content = json_decode ('{"foo":123} ' );
82- $ schema = file_get_contents (self :: getSchema ('test.schema.json ' ));
72+ $ schema = file_get_contents (Utils:: getSchemaPath ('test.schema.json ' ));
8373
8474 AssertTraitImpl::assertJsonMatchesSchemaString ($ schema , $ content );
8575 }
@@ -94,7 +84,7 @@ public function testAssertJsonMatchesSchemaString()
9484 */
9585 public function testAssertJsonValueEquals ($ expression , $ value )
9686 {
97- $ content = json_decode (file_get_contents (self :: getJson ('testAssertJsonValueEquals.json ' )));
87+ $ content = json_decode (file_get_contents (Utils:: getJsonPath ('testAssertJsonValueEquals.json ' )));
9888
9989 AssertTraitImpl::assertJsonValueEquals ($ value , $ expression , $ content );
10090 }
@@ -112,7 +102,7 @@ public function assertJsonValueEqualsProvider()
112102 */
113103 public function testAssertJsonValueEqualsFailsOnWrongDataType ()
114104 {
115- $ content = json_decode (file_get_contents (self :: getJson ('testAssertJsonValueEquals.json ' )));
105+ $ content = json_decode (file_get_contents (Utils:: getJsonPath ('testAssertJsonValueEquals.json ' )));
116106
117107 AssertTraitImpl::assertJsonValueEquals ($ content , 'a.b.c[0].d[1][0] ' , '1 ' );
118108 }
0 commit comments