class ConfigOperationsProviderTest in Payment 8.2
@coversDefaultClass \Drupal\payment\Plugin\Payment\Status\ConfigOperationsProvider
@group Payment
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\payment\Unit\Plugin\Payment\Status\ConfigOperationsProviderTest
Expanded class hierarchy of ConfigOperationsProviderTest
File
- tests/
src/ Unit/ Plugin/ Payment/ Status/ ConfigOperationsProviderTest.php, line 18
Namespace
Drupal\Tests\payment\Unit\Plugin\Payment\StatusView source
class ConfigOperationsProviderTest extends UnitTestCase {
/**
* The payment status list builder.
*
* @var \Drupal\Core\Entity\EntityListBuilderInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $paymentStatusListBuilder;
/**
* The payment status storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $paymentStatusStorage;
/**
* The class under test.
*
* @var \Drupal\payment\Plugin\Payment\Status\ConfigOperationsProvider
*/
protected $sut;
/**
* {@inheritdoc}
*/
public function setUp() : void {
$this->paymentStatusListBuilder = $this
->createMock(EntityListBuilderInterface::class);
$this->paymentStatusStorage = $this
->createMock(EntityStorageInterface::class);
$this->sut = new ConfigOperationsProvider($this->paymentStatusStorage, $this->paymentStatusListBuilder);
}
/**
* @covers ::create
* @covers ::__construct
*/
public function testCreate() {
$entity_type_manager = $this
->createMock(EntityTypeManagerInterface::class);
$entity_type_manager
->expects($this
->once())
->method('getStorage')
->with('payment_status')
->willReturn($this->paymentStatusStorage);
$entity_type_manager
->expects($this
->once())
->method('getListBuilder')
->with('payment_status')
->willReturn($this->paymentStatusListBuilder);
$container = $this
->createMock(ContainerInterface::class);
$container
->expects($this
->once())
->method('get')
->with('entity_type.manager')
->willReturn($entity_type_manager);
$this
->assertInstanceOf(ConfigOperationsProvider::class, ConfigOperationsProvider::create($container));
}
/**
* @covers ::getOperations
*/
public function testGetOperations() {
$entity_id = $this
->randomMachineName();
$plugin_id = 'payment_config:' . $entity_id;
$payment_status = $this
->createMock(PaymentStatusInterface::class);
$this->paymentStatusStorage
->expects($this
->once())
->method('load')
->with($entity_id)
->willReturn($payment_status);
$operations = array(
'foo' => array(
'title' => $this
->randomMachineName(),
),
);
$this->paymentStatusListBuilder
->expects($this
->once())
->method('getOperations')
->with($payment_status)
->willReturn($operations);
$this
->assertSame($operations, $this->sut
->getOperations($plugin_id));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigOperationsProviderTest:: |
protected | property | The payment status list builder. | |
ConfigOperationsProviderTest:: |
protected | property | The payment status storage. | |
ConfigOperationsProviderTest:: |
protected | property | The class under test. | |
ConfigOperationsProviderTest:: |
public | function |
Overrides UnitTestCase:: |
|
ConfigOperationsProviderTest:: |
public | function | @covers ::create @covers ::__construct | |
ConfigOperationsProviderTest:: |
public | function | @covers ::getOperations | |
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. |