class CurrencyTest in Currency 8.3
Same name in this branch
- 8.3 tests/src/Kernel/CurrencyTest.php \Drupal\Tests\currency\Kernel\CurrencyTest
- 8.3 tests/src/Unit/Entity/CurrencyTest.php \Drupal\Tests\currency\Unit\Entity\CurrencyTest
- 8.3 tests/src/Unit/Plugin/views/filter/CurrencyTest.php \Drupal\Tests\currency\Unit\Plugin\views\filter\CurrencyTest
- 8.3 tests/src/Unit/Plugin/views/field/CurrencyTest.php \Drupal\Tests\currency\Unit\Plugin\views\field\CurrencyTest
@coversDefaultClass \Drupal\currency\Plugin\views\filter\Currency
@group Currency
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\currency\Unit\Plugin\views\filter\CurrencyTest
Expanded class hierarchy of CurrencyTest
File
- tests/
src/ Unit/ Plugin/ views/ filter/ CurrencyTest.php, line 15
Namespace
Drupal\Tests\currency\Unit\Plugin\views\filterView source
class CurrencyTest extends UnitTestCase {
/**
* The form helper
*
* @var \Drupal\currency\FormHelperInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $formHelper;
/**
* The class under test.
*
* @var \Drupal\currency\Plugin\views\field\Currency
*/
protected $sut;
/**
* {@inheritdoc}
*/
public function setUp() : void {
$configuration = [];
$plugin_id = $this
->randomMachineName();
$plugin_definition = [];
$this->formHelper = $this
->createMock(FormHelperInterface::class);
$this->sut = new Currency($configuration, $plugin_id, $plugin_definition, $this->formHelper);
}
/**
* @covers ::create
* @covers ::__construct
*/
function testCreate() {
$container = $this
->createMock(ContainerInterface::class);
$map = [
[
'currency.form_helper',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$this->formHelper,
],
];
$container
->expects($this
->any())
->method('get')
->willReturnMap($map);
$configuration = [];
$plugin_id = $this
->randomMachineName();
$plugin_definition = [];
$sut = Currency::create($container, $configuration, $plugin_id, $plugin_definition);
$this
->assertInstanceOf(Currency::class, $sut);
}
/**
* @covers ::getValueOptions
*/
public function testGetValueOptions() {
$options = array(
$this
->randomMachineName() => $this
->randomMachineName(),
);
$this->formHelper
->expects($this
->atLeastOnce())
->method('getCurrencyOptions')
->willReturn($options);
$method = new \ReflectionMethod($this->sut, 'getValueOptions');
$method
->setAccessible(TRUE);
$this
->assertSame($options, $method
->invoke($this->sut));
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CurrencyTest:: |
protected | property | The form helper | |
CurrencyTest:: |
protected | property | The class under test. | |
CurrencyTest:: |
public | function |
Overrides UnitTestCase:: |
|
CurrencyTest:: |
function | @covers ::create @covers ::__construct | ||
CurrencyTest:: |
public | function | @covers ::getValueOptions | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |