ObjectDefinition example

/** * @covers ::findDefinitions * @covers ::extractProviderFromDefinition */
  public function testProviderExists() {
    $definitions = [];
    $definitions['array_based_found'] = ['provider' => 'module_found'];
    $definitions['array_based_missing'] = ['provider' => 'module_missing'];
    $definitions['stdclass_based_found'] = (object) ['provider' => 'module_found'];
    $definitions['stdclass_based_missing'] = (object) ['provider' => 'module_missing'];
    $definitions['classed_object_found'] = new ObjectDefinition(['provider' => 'module_found']);
    $definitions['classed_object_missing'] = new ObjectDefinition(['provider' => 'module_missing']);

    $expected = [];
    $expected['array_based_found'] = $definitions['array_based_found'];
    $expected['stdclass_based_found'] = $definitions['stdclass_based_found'];
    $expected['classed_object_found'] = $definitions['classed_object_found'];

    $module_handler = $this->prophesize(ModuleHandlerInterface::class);
    $module_handler->moduleExists('module_found')->willReturn(TRUE)->shouldBeCalled();
    $module_handler->moduleExists('module_missing')->willReturn(FALSE)->shouldBeCalled();
    $plugin_manager = new TestPluginManager($this->namespaces, $definitions$module_handler->reveal());
    

class AnnotationBridgeDecoratorTest extends TestCase {

  use ProphecyTrait;

  /** * @covers ::getDefinitions */
  public function testGetDefinitions() {
    $definitions = [];
    $definitions['object'] = new ObjectDefinition(['id' => 'foo']);
    $definitions['array'] = ['id' => 'bar'];
    $discovery = $this->prophesize(DiscoveryInterface::class);
    $discovery->getDefinitions()->willReturn($definitions);

    $decorator = new AnnotationBridgeDecorator($discovery->reveal(), TestAnnotation::class);

    $expected = [
      'object' => new ObjectDefinition(['id' => 'foo']),
      'array' => new ObjectDefinition(['id' => 'bar']),
    ];
    $this->assertEquals($expected$decorator->getDefinitions());
  }
Home | Imprint | This part of the site doesn't use cookies.