/** * forget a factory * * @param string $factoryName * the factory that we want to forget */ public function offsetUnset($factoryName) { // are we allowed to edit this container? RequireWriteableContainer::apply(null, [RequireWriteableContainer::class])->to($this, '$this'); // it's PHP convention that attempting to unset() something that is // already unset() is not considered an error if (!isset($this->factories[$factoryName])) { return; } // forget the factory unset($this->factories[$factoryName]); }
/** * @covers ::apply * @covers ::to */ public function test_does_not_throw_exception_when_container_is_read_write() { // ---------------------------------------------------------------- // setup your test $container = new FactoryListContainer(["hello" => [ContainerIsReadOnly::class, 'newFromVar']]); $container->setReadWrite(); // ---------------------------------------------------------------- // perform the change RequireWriteableContainer::apply()->to($container); // ---------------------------------------------------------------- // test the results $this->assertTrue($container->isReadWrite()); }