Nelmio\Alice\Definition\PropertyBagTest::testMergeTwoBags PHP Метод

testMergeTwoBags() публичный Метод

public testMergeTwoBags ( )
    public function testMergeTwoBags()
    {
        $propertyA1 = new Property('username', 'alice');
        $propertyA2 = new Property('owner', 'bob');
        $propertyB1 = new Property('username', 'mad');
        // overlapping value
        $propertyB2 = new Property('mail', '[email protected]');
        $bagA = (new PropertyBag())->with($propertyA1)->with($propertyA2);
        $bagB = (new PropertyBag())->with($propertyB1)->with($propertyB2);
        $bag = $bagA->mergeWith($bagB);
        $this->assertInstanceOf(PropertyBag::class, $bag);
        $this->assertSame(['username' => $propertyA1, 'owner' => $propertyA2], $this->propRefl->getValue($bagA));
        $this->assertSame(['username' => $propertyB1, 'mail' => $propertyB2], $this->propRefl->getValue($bagB));
        $this->assertSame(['username' => $propertyA1, 'mail' => $propertyB2, 'owner' => $propertyA2], $this->propRefl->getValue($bag));
    }