forked from docker-php/docker-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiJsonStreamTest.php
More file actions
61 lines (52 loc) · 1.59 KB
/
Copy pathMultiJsonStreamTest.php
File metadata and controls
61 lines (52 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace Docker\Tests\Stream;
use Docker\API\Model\BuildInfo;
use Docker\Stream\MultiJsonStream;
use Docker\Tests\TestCase;
use GuzzleHttp\Psr7\BufferStream;
use Symfony\Component\Serializer\SerializerInterface;
class MultiJsonStreamTest extends TestCase
{
public function jsonStreamDataProvider()
{
return [
[
'{}{"abc":"def"}',
['{}', '{"abc":"def"}'],
],
[
'{"test": "abc\"\""}',
['{"test":"abc\"\""}'],
],
[
'{"test": "abc\"{{-}"}',
['{"test":"abc\"{{-}"}'],
],
];
}
/**
* @param $jsonStream
* @param $jsonParts
* @dataProvider jsonStreamDataProvider
*/
public function testReadJsonEscapedDoubleQuote(string $jsonStream, array $jsonParts): void
{
$stream = new BufferStream();
$stream->write($jsonStream);
$serializer = $this->getMockBuilder(SerializerInterface::class)
->getMock();
$serializer
->expects($this->exactly(\count($jsonParts)))
->method('deserialize')
->withConsecutive(...\array_map(function ($part) {
return [$part, BuildInfo::class, 'json', []];
}, $jsonParts))
;
$stub = $this->getMockForAbstractClass(MultiJsonStream::class, [$stream, $serializer]);
$stub->expects($this->any())
->method('getDecodeClass')
->willReturn('BuildInfo');
$stub->wait();
}
}