public function testWithersReturnNewModifiedInstance() { $reference = 'user0'; $specs = SpecificationBagFactory::create(); $newSpecs = SpecificationBagFactory::create(new FakeMethodCall()); $newDecoratedFixtureProphecy = $this->prophesize(FixtureInterface::class); $newDecoratedFixtureProphecy->getSpecs()->willReturn($newSpecs); /** @var FixtureInterface $newDecoratedFixture */ $newDecoratedFixture = $newDecoratedFixtureProphecy->reveal(); $decoratedFixtureProphecy = $this->prophesize(FixtureInterface::class); $decoratedFixtureProphecy->getId()->willReturn($reference); $decoratedFixtureProphecy->withSpecs($newSpecs)->willReturn($newDecoratedFixture); $decoratedFixtureProphecy->getSpecs()->willReturn($specs); /** @var FixtureInterface $decoratedFixture */ $decoratedFixture = $decoratedFixtureProphecy->reveal(); $flags = new FlagBag('user0'); $fixture = new SimpleFixtureWithFlags($decoratedFixture, $flags); $newFixture = $fixture->withSpecs($newSpecs); $this->assertInstanceOf(SimpleFixtureWithFlags::class, $newFixture); $this->assertNotSame($fixture, $newFixture); $this->assertEquals($specs, $fixture->getSpecs()); $this->assertEquals($flags, $fixture->getFlags()); $this->assertEquals($newSpecs, $newFixture->getSpecs()); $this->assertEquals($flags, $newFixture->getFlags()); }