ManagerTest.php in Message Subscribe 8
File
message_subscribe_email/tests/src/Unit/ManagerTest.php
View source
<?php
namespace Drupal\Tests\message_subscribe_email\Unit;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\flag\FlagInterface;
use Drupal\flag\FlagServiceInterface;
use Drupal\message_subscribe_email\Manager;
use Drupal\Tests\UnitTestCase;
class ManagerTest extends UnitTestCase {
public function testGetFlags(array $expected, array $flags) {
$flag_service = $this
->prophesize(FlagServiceInterface::class);
$flag_service
->getAllFlags()
->willReturn($flags);
$config = $this
->prophesize(ImmutableConfig::class);
$config
->get('flag_prefix')
->willReturn('non_standard_prefix');
$config_factory = $this
->prophesize(ConfigFactoryInterface::class);
$config_factory
->get('message_subscribe_email.settings')
->willReturn($config
->reveal());
$manager = new Manager($flag_service
->reveal(), $config_factory
->reveal());
$this
->assertEquals($expected, $manager
->getFlags());
}
public function providerTestGetFlags() {
$return[] = [
[],
[],
];
$flag = $this
->prophesize(FlagInterface::class)
->reveal();
$return[] = [
[],
[
'foo_flag' => $flag,
],
];
$return[] = [
[
'non_standard_prefix_one' => $flag,
'non_standard_prefix_two' => $flag,
],
[
'foo_flag' => $flag,
'non_standard_prefix_one' => $flag,
'non_standard_prefix_two' => $flag,
],
];
return $return;
}
}
Classes
Name |
Description |
ManagerTest |
Unit tests for the message subscribe email manager utility class. |