DefaultSingleLazyPluginCollectionTest.php in Zircon Profile 8
File
core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
View source
<?php
namespace Drupal\Tests\Core\Plugin;
use Drupal\Core\Plugin\DefaultSingleLazyPluginCollection;
class DefaultSingleLazyPluginCollectionTest extends LazyPluginCollectionTestBase {
protected function setupPluginCollection(\PHPUnit_Framework_MockObject_Matcher_InvokedRecorder $create_count = NULL) {
$definitions = $this
->getPluginDefinitions();
$this->pluginInstances['apple'] = $this
->getPluginMock('apple', $definitions['apple']);
$create_count = $create_count ?: $this
->never();
$this->pluginManager
->expects($create_count)
->method('createInstance')
->will($this
->returnValue($this->pluginInstances['apple']));
$this->defaultPluginCollection = new DefaultSingleLazyPluginCollection($this->pluginManager, 'apple', array(
'id' => 'apple',
'key' => 'value',
));
}
public function testGet() {
$this
->setupPluginCollection($this
->once());
$apple = $this->pluginInstances['apple'];
$this
->assertSame($apple, $this->defaultPluginCollection
->get('apple'));
}
}