public withConstructor ( Nelmio\Alice\Definition\MethodCallInterface $constructor = null ) : self | ||
$constructor | Nelmio\Alice\Definition\MethodCallInterface | |
return | self |
public function testWithersReturnNewModifiedInstance() { $constructor = null; $properties = new PropertyBag(); $calls = new MethodCallBag(); $bag = new SpecificationBag($constructor, $properties, $calls); $newConstructor = new FakeMethodCall(); $newBag = $bag->withConstructor($newConstructor); $this->assertInstanceOf(SpecificationBag::class, $newBag); $this->assertEquals($constructor, $bag->getConstructor()); $this->assertEquals($calls, $bag->getMethodCalls()); $this->assertEquals($properties, $bag->getProperties()); $this->assertEquals(new FakeMethodCall(), $newBag->getConstructor()); $this->assertEquals($calls, $newBag->getMethodCalls()); $this->assertEquals($properties, $newBag->getProperties()); }