VoteUpDownWidgetManagerTest.php in Vote Up/Down 8
File
tests/src/Unit/VoteUpDownWidgetManagerTest.php
View source
<?php
namespace Drupal\Tests\vud\Unit;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Tests\UnitTestCase;
use Drupal\vud\Plugin\VoteUpDownWidgetManager;
class VoteUpDownWidgetManagerTest extends UnitTestCase {
protected $voteUpDownWidgetManager;
protected function setUp() {
parent::setUp();
$cache_backend = $this
->prophesize(CacheBackendInterface::class);
$module_handler = $this
->prophesize(ModuleHandlerInterface::class);
$this->voteUpDownWidgetManager = new VoteUpDownWidgetManager(new \ArrayObject(), $cache_backend
->reveal(), $module_handler
->reveal());
$discovery = $this
->prophesize(DiscoveryInterface::class);
$discovery
->getDefinitions()
->willReturn([
'newPlugin' => [
'id' => 'new_plugin',
'admin_label' => @t('New Plugin'),
'description' => 'New plugin type',
],
]);
$property = new \ReflectionProperty(VoteUpDownWidgetManager::class, 'discovery');
$property
->setAccessible(TRUE);
$property
->setValue($this->voteUpDownWidgetManager, $discovery
->reveal());
}
public function testDefinitions() {
$definitions = $this->voteUpDownWidgetManager
->getDefinitions();
$this
->assertSame([
'newPlugin',
], array_keys($definitions));
}
}