Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

Commit 6024586

Browse files
author
Andrey Helldar
committed
Added collision test
1 parent d22a3c6 commit 6024586

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/ResponseServiceTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,20 @@ public function testStatusCode()
7777
$this->assertEquals(401, api_response('ok', 401)->getStatusCode());
7878
$this->assertEquals(500, api_response('ok', 500)->getStatusCode());
7979
}
80+
81+
public function testKeyCollisionTesting()
82+
{
83+
$this->assertEquals(json_encode(['data' => 'example', 'foo' => 'bar']), api_response(['data' => 'example', 'foo' => 'bar'])->getContent());
84+
$this->assertEquals(json_encode(['data' => ['example', 'foo' => 'bar']]), api_response(['data' => ['example', 'foo' => 'bar']])->getContent());
85+
86+
$this->assertEquals(
87+
json_encode(['error' => ['code' => 400, 'data' => 'example'], 'foo' => 'bar']),
88+
api_response(['data' => 'example', 'foo' => 'bar'], 400)->getContent()
89+
);
90+
91+
$this->assertEquals(
92+
json_encode(['error' => ['code' => 400, 'data' => ['foo' => 'bar', 'baz' => 'baq']]]),
93+
api_response(['data' => ['foo' => 'bar', 'baz' => 'baq']], 400)->getContent()
94+
);
95+
}
8096
}

0 commit comments

Comments
 (0)