public function DefaultPluginManagerTest::setUp in Service Container 7.2
Same name and namespace in other branches
- 7 tests/src/Plugin/DefaultPluginManagerTest.php \Drupal\Tests\service_container\Plugin\DefaultPluginManagerTest::setUp()
File
- tests/
src/ Plugin/ DefaultPluginManagerTest.php, line 25 - Contains \Drupal\Tests\service_container\Plugin\DefaultPluginManagerTest
Class
- DefaultPluginManagerTest
- @coversDefaultClass \Drupal\service_container\Plugin\DefaultPluginManager @group dic
Namespace
Drupal\Tests\service_container\PluginCode
public function setUp() {
$foo = Mockery::mock('\\stdClass');
$foo_class = get_class($foo);
$this->definitions = array(
'foo' => array(
'class' => $foo_class,
),
);
$discovery = Mockery::mock('\\Drupal\\Component\\Plugin\\Discovery\\DiscoveryInterface');
$discovery
->shouldReceive('getDefinition')
->with('foo')
->andReturn($this->definitions['foo']);
$discovery
->shouldReceive('getDefinition')
->with('foo', TRUE)
->andReturn($this->definitions['foo']);
$discovery
->shouldReceive('getDefinition')
->with('foo', FALSE)
->andReturn($this->definitions['foo']);
$discovery
->shouldReceive('getDefinition')
->with('bar', FALSE);
$discovery
->shouldReceive('getDefinition')
->with('bar', TRUE)
->andThrow(new PluginNotFoundException('bar'));
$discovery
->shouldReceive('getDefinition')
->with('bar')
->andThrow(new PluginNotFoundException('bar'));
$discovery
->shouldReceive('hasDefinition')
->with('foo')
->andReturn(TRUE);
$discovery
->shouldReceive('hasDefinition')
->with('bar')
->andReturn(FALSE);
$discovery
->shouldReceive('getDefinitions')
->andReturn($this->definitions);
$discovery
->shouldReceive('createInstance')
->with('foo', array())
->andReturn(new $foo_class());
$discovery
->shouldReceive('getInstance')
->with('foo')
->andReturn(new $foo_class());
$this->pluginManager = new DefaultPluginManager($discovery);
$plugin_manager = $this->pluginManager;
$this->fallbackPluginManager = Mockery::mock('\\Drupal\\Tests\\service_container\\Plugin\\TestFallbackPluginManager[getFallbackPluginId]', array(
$discovery,
));
$this->fallbackPluginManager
->shouldReceive('getFallbackPluginId')
->with('bar', array())
->andReturn('foo');
}