public function testMergeTwoBags()
{
$constructorA = null;
$constructorB = null;
$propertyA1 = new Property('username', 'alice');
$propertyA2 = new Property('owner', 'bob');
$propertyB1 = new Property('username', 'mad');
$propertyB2 = new Property('mail', '[email protected]');
$propertiesA = (new PropertyBag())->with($propertyA1)->with($propertyA2);
$propertiesB = (new PropertyBag())->with($propertyB1)->with($propertyB2);
$callA1 = new SimpleMethodCall('setUsername', []);
$callA2 = new SimpleMethodCall('setOwner', []);
$callB1 = new SimpleMethodCall('setUsername', []);
$callB2 = new SimpleMethodCall('setMail', []);
$callsA = (new MethodCallBag())->with($callA1)->with($callA2);
$callsB = (new MethodCallBag())->with($callB1)->with($callB2);
$bagA = new SpecificationBag($constructorA, $propertiesA, $callsA);
$bagB = new SpecificationBag($constructorB, $propertiesB, $callsB);
$bag = $bagA->mergeWith($bagB);
$this->assertInstanceOf(SpecificationBag::class, $bag);
$this->assertEquals($constructorA, $bagA->getConstructor());
$this->assertEquals($propertiesA, $bagA->getProperties());
$this->assertEquals($callsA, $bagA->getMethodCalls());
$this->assertEquals($constructorB, $bagB->getConstructor());
$this->assertEquals($propertiesB, $bagB->getProperties());
$this->assertEquals($callsB, $bagB->getMethodCalls());
$this->assertEquals($constructorA, $bag->getConstructor());
}