builder = Builder::create(); } public function test_create() { $this->assertInstanceOf(Builder::class, $this->builder); } public function test_build() { $this->assertInstanceOf(RegistryContainerInterface::class, $this->builder->build()); } public function test_withRegistryClass() { $registry = $this->builder->withRegistryClass(MockRegistry::class)->build(); $this->assertInstanceOf(MockRegistry::class, $registry); } public function test_withRegistryClass_throws_InvalidArgumentException() { $this->expectException(InvalidArgumentException::class); $this->builder->withRegistryClass(\stdClass::class); } public function test_withRegistryClass_returns_cloned() { $this->assertNotSame($this->builder, $this->builder->withRegistryClass(MockRegistry::class)); } public function test_withTypesMap() { /** @var MockRegistry $registry */ $registry = $this->builder ->withRegistryClass(MockRegistry::class) ->withTypesMap(['test' => 'test']) ->build(); $this->assertArrayHasKey('test', $registry->getTypesMap()); } public function test_withTypesMap_rewrites_map() { /** @var MockRegistry $registry */ $registry = $this->builder ->withRegistryClass(MockRegistry::class) ->withTypesMap(['test' => 'test']) ->withTypesMap(['test2' => 'test2']) ->build(); $this->assertArrayHasKey('test2', $registry->getTypesMap()); $this->assertArrayNotHasKey('test', $registry->getTypesMap()); } public function test_withTypesMap_merges_maps() { /** @var MockRegistry $registry */ $registry = $this->builder ->withRegistryClass(MockRegistry::class) ->withTypesMap(['test' => 'test']) ->withTypesMap(['test2' => 'test2'], true) ->build(); $this->assertArrayHasKey('test', $registry->getTypesMap()); $this->assertArrayHasKey('test2', $registry->getTypesMap()); } public function test_withTypesMap_returns_cloned() { $this->assertNotSame($this->builder, $this->builder->withTypesMap(['test2' => 'test2'])); } }