Skip to content

Commit 03e5987

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: [LokaliseBridge] Fix push command --delete-missing options when there are no missing messages fix bad help message in cache warmup command [Console] Fix OutputFormatterStyleStack::getCurrent return type Count cookie parts before accessing the second Fix RequestStack state if throwable is thrown [Serializer] Fix caching context-aware encoders/decoders in ChainEncoder/ChainDecoder
2 parents 54bee48 + 18c9a81 commit 03e5987

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Tests/Encoder/ChainDecoderTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ protected function setUp(): void
3737
[self::FORMAT_2, [], false],
3838
[self::FORMAT_3, [], false],
3939
[self::FORMAT_3, ['foo' => 'bar'], true],
40+
[self::FORMAT_3, ['foo' => 'bar2'], false],
4041
]);
4142

4243
$this->decoder2 = $this->createMock(DecoderInterface::class);
@@ -46,17 +47,35 @@ protected function setUp(): void
4647
[self::FORMAT_1, [], false],
4748
[self::FORMAT_2, [], true],
4849
[self::FORMAT_3, [], false],
50+
[self::FORMAT_3, ['foo' => 'bar'], false],
51+
[self::FORMAT_3, ['foo' => 'bar2'], true],
4952
]);
5053

5154
$this->chainDecoder = new ChainDecoder([$this->decoder1, $this->decoder2]);
5255
}
5356

5457
public function testSupportsDecoding()
5558
{
59+
$this->decoder1
60+
->method('decode')
61+
->willReturn('result1');
62+
$this->decoder2
63+
->method('decode')
64+
->willReturn('result2');
65+
5666
$this->assertTrue($this->chainDecoder->supportsDecoding(self::FORMAT_1));
67+
$this->assertEquals('result1', $this->chainDecoder->decode('', self::FORMAT_1, []));
68+
5769
$this->assertTrue($this->chainDecoder->supportsDecoding(self::FORMAT_2));
70+
$this->assertEquals('result2', $this->chainDecoder->decode('', self::FORMAT_2, []));
71+
5872
$this->assertFalse($this->chainDecoder->supportsDecoding(self::FORMAT_3));
73+
5974
$this->assertTrue($this->chainDecoder->supportsDecoding(self::FORMAT_3, ['foo' => 'bar']));
75+
$this->assertEquals('result1', $this->chainDecoder->decode('', self::FORMAT_3, ['foo' => 'bar']));
76+
77+
$this->assertTrue($this->chainDecoder->supportsDecoding(self::FORMAT_3, ['foo' => 'bar2']));
78+
$this->assertEquals('result2', $this->chainDecoder->decode('', self::FORMAT_3, ['foo' => 'bar2']));
6079
}
6180

6281
public function testDecode()

Tests/Encoder/ChainEncoderTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ protected function setUp(): void
3939
[self::FORMAT_2, [], false],
4040
[self::FORMAT_3, [], false],
4141
[self::FORMAT_3, ['foo' => 'bar'], true],
42+
[self::FORMAT_3, ['foo' => 'bar2'], false],
4243
]);
4344

4445
$this->encoder2 = $this->createMock(EncoderInterface::class);
@@ -48,17 +49,35 @@ protected function setUp(): void
4849
[self::FORMAT_1, [], false],
4950
[self::FORMAT_2, [], true],
5051
[self::FORMAT_3, [], false],
52+
[self::FORMAT_3, ['foo' => 'bar'], false],
53+
[self::FORMAT_3, ['foo' => 'bar2'], true],
5154
]);
5255

5356
$this->chainEncoder = new ChainEncoder([$this->encoder1, $this->encoder2]);
5457
}
5558

5659
public function testSupportsEncoding()
5760
{
61+
$this->encoder1
62+
->method('encode')
63+
->willReturn('result1');
64+
$this->encoder2
65+
->method('encode')
66+
->willReturn('result2');
67+
5868
$this->assertTrue($this->chainEncoder->supportsEncoding(self::FORMAT_1));
69+
$this->assertEquals('result1', $this->chainEncoder->encode('', self::FORMAT_1, []));
70+
5971
$this->assertTrue($this->chainEncoder->supportsEncoding(self::FORMAT_2));
72+
$this->assertEquals('result2', $this->chainEncoder->encode('', self::FORMAT_2, []));
73+
6074
$this->assertFalse($this->chainEncoder->supportsEncoding(self::FORMAT_3));
75+
6176
$this->assertTrue($this->chainEncoder->supportsEncoding(self::FORMAT_3, ['foo' => 'bar']));
77+
$this->assertEquals('result1', $this->chainEncoder->encode('', self::FORMAT_3, ['foo' => 'bar']));
78+
79+
$this->assertTrue($this->chainEncoder->supportsEncoding(self::FORMAT_3, ['foo' => 'bar2']));
80+
$this->assertEquals('result2', $this->chainEncoder->encode('', self::FORMAT_3, ['foo' => 'bar2']));
6281
}
6382

6483
public function testEncode()

0 commit comments

Comments
 (0)