public function testCaseFactoryPlugin_RegistersAndUnregistersItself()
{
$std = new StdClass();
$register = function (FactoryInterface $factory) use($std) {
$factory->define('Mock', function () use($std) {
return $std;
});
};
$unregister = function (FactoryInterface $factory) {
$factory->remove('Mock');
};
$factory = $this->createFactory();
$plugin = $this->createFactoryPlugin($register, $unregister);
$plugin->registerPlugin($factory);
$this->assertSame($std, $factory->create('Mock'));
$ex = null;
try {
$plugin->unregisterPlugin($factory);
$factory->create('Mock');
} catch (Exception $ex) {
}
$this->assertInstanceOf(IllegalCallException::class, $ex);
unset($plugin);
unset($factory);
}