Exemplo n.º 1
0
    /**
     * @test
     */
    public function it_construct_a_valid_json_with_data()
    {
        $targetAdd = '{
				"first_data":"first",
				"second_data":true
			}';
        $targetSet = '
				{
					"third_data":"third",
					"fourth_data":4
				}';
        $dataBuilder = new PayloadDataBuilder();
        $dataBuilder->addData(['first_data' => 'first'])->addData(['second_data' => true]);
        $json = json_encode($dataBuilder->build()->toArray());
        $this->assertJsonStringEqualsJsonString($targetAdd, $json);
        $dataBuilder->setData(['third_data' => 'third', 'fourth_data' => 4]);
        $json = json_encode($dataBuilder->build()->toArray());
        $this->assertJsonStringEqualsJsonString($targetSet, $json);
    }
Exemplo n.º 2
0
 /**
  * PayloadData constructor.
  *
  * @param PayloadDataBuilder $builder
  */
 public function __construct(PayloadDataBuilder $builder)
 {
     $this->data = $builder->getData();
 }