Nelmio\Alice\Definition\MethodCallBagTest::testMergeTwoBags PHP Method

testMergeTwoBags() public method

public testMergeTwoBags ( )
    public function testMergeTwoBags()
    {
        $callA1 = new SimpleMethodCall('setUsername', []);
        $callA2 = new SimpleMethodCall('setOwner', []);
        $callB1 = new SimpleMethodCall('setUsername', []);
        $callB2 = new SimpleMethodCall('setMail', []);
        $bagA = (new MethodCallBag())->with($callA1)->with($callA2);
        $bagB = (new MethodCallBag())->with($callB1)->with($callB2);
        $bag = $bagA->mergeWith($bagB);
        $this->assertInstanceOf(MethodCallBag::class, $bag);
        $this->assertSame([$callA1, $callA2], $this->propRefl->getValue($bagA));
        $this->assertSame([$callB1, $callB2], $this->propRefl->getValue($bagB));
        $this->assertSame([$callB1, $callB2, $callA1, $callA2], $this->propRefl->getValue($bag));
    }