Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ArgumentsSerializationTest.php
Go to the documentation of this file.
1 <?php
8 
11 
18 class ArgumentsSerializationTest extends \PHPUnit\Framework\TestCase
19 {
23  private $serializer;
24 
28  protected function setUp()
29  {
30  $this->serializer = $this->getMockBuilder(SerializerInterface::class)
31  ->getMock();
32  $this->serializer->expects($this->any())->method('serialize')->willReturnCallback(function ($param) {
33  return json_encode($param);
34  });
35  }
36 
38  {
39  $inputConfig = [
40  'data' => []
41  ];
42  $modifier = new ArgumentsSerialization($this->serializer);
43  $this->assertSame($inputConfig, $modifier->modify($inputConfig));
44  }
45 
46  public function testModifyArguments()
47  {
48  $inputConfig = [
49  'arguments' => [
50  'argument1' => [],
51  'argument2' => null,
52  ]
53  ];
54 
55  $expected = [
56  'arguments' => [
57  'argument1' => json_encode([]),
58  'argument2' => null,
59  ]
60  ];
61 
62  $modifier = new ArgumentsSerialization($this->serializer);
63  $this->assertEquals($expected, $modifier->modify($inputConfig));
64  }
65 }