class PaymentStatusTest in Payment 8.2
Same name in this branch
- 8.2 tests/src/Unit/Entity/PaymentStatusTest.php \Drupal\Tests\payment\Unit\Entity\PaymentStatusTest
- 8.2 tests/src/Unit/Plugin/views/filter/PaymentStatusTest.php \Drupal\Tests\payment\Unit\Plugin\views\filter\PaymentStatusTest
@coversDefaultClass \Drupal\payment\Entity\PaymentStatus
@group Payment
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\payment\Unit\Entity\PaymentStatusTest
Expanded class hierarchy of PaymentStatusTest
File
- tests/
src/ Unit/ Entity/ PaymentStatusTest.php, line 16
Namespace
Drupal\Tests\payment\Unit\EntityView source
class PaymentStatusTest extends UnitTestCase {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $entityTypeManager;
/**
* The entity type ID.
*
* @var string
*/
protected $entityTypeId;
/**
* The class under test.
*
* @var \Drupal\payment\Entity\PaymentStatus
*/
protected $sut;
/**
* The typed config manager.
*
* @var \Drupal\Core\Config\TypedConfigManagerInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $typedConfigManager;
/**
* {@inheritdoc}
*
* @covers ::setEntityTypeManager
* @covers ::setTypedConfig
*/
public function setUp() : void {
$this->entityTypeManager = $this
->createMock(EntityTypeManagerInterface::class);
$this->entityTypeId = $this
->randomMachineName();
$this->typedConfigManager = $this
->createMock(TypedConfigManagerInterface::class);
$this->sut = new PaymentStatus([], $this->entityTypeId);
$this->sut
->setEntityTypeManager($this->entityTypeManager);
$this->sut
->setTypedConfig($this->typedConfigManager);
}
/**
* @covers ::id
* @covers ::setId
*/
public function testId() {
$id = strtolower($this
->randomMachineName());
$this
->assertSame($this->sut, $this->sut
->setId($id));
$this
->assertSame($id, $this->sut
->id());
}
/**
* @covers ::setLabel
* @covers ::label
*/
public function testLabel() {
$entity_type = $this
->createMock(ConfigEntityTypeInterface::class);
$entity_type
->expects($this
->atLeastOnce())
->method('getKey')
->with('label')
->willReturn('label');
$this->entityTypeManager
->expects($this
->atLeastOnce())
->method('getDefinition')
->with($this->entityTypeId)
->willReturn($entity_type);
$label = $this
->randomMachineName();
$this
->assertSame($this->sut, $this->sut
->setLabel($label));
$this
->assertSame($label, $this->sut
->label());
}
/**
* @covers ::getParentId
* @covers ::setParentId
*/
public function testGetParentId() {
$id = strtolower($this
->randomMachineName());
$this
->assertSame($this->sut, $this->sut
->setParentId($id));
$this
->assertSame($id, $this->sut
->getParentId());
}
/**
* @covers ::getDescription
* @covers ::setDescription
*/
public function testGetDescription() {
$description = $this
->randomMachineName();
$this
->assertSame($this->sut, $this->sut
->setDescription($description));
$this
->assertSame($description, $this->sut
->getDescription());
}
/**
* @covers ::entityTypeManager
*/
public function testEntityTypeManager() {
$method = new \ReflectionMethod($this->sut, 'entityTypeManager');
$method
->setAccessible(TRUE);
$this
->assertSame($this->entityTypeManager, $method
->invoke($this->sut));
}
/**
* @covers ::getTypedConfig
*/
public function testGetTypedConfig() {
$method = new \ReflectionMethod($this->sut, 'getTypedConfig');
$method
->setAccessible(TRUE);
$this
->assertSame($this->typedConfigManager, $method
->invoke($this->sut));
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PaymentStatusTest:: |
protected | property | The entity type ID. | |
PaymentStatusTest:: |
protected | property | The entity type manager. | |
PaymentStatusTest:: |
protected | property | The class under test. | |
PaymentStatusTest:: |
protected | property | The typed config manager. | |
PaymentStatusTest:: |
public | function |
@covers ::setEntityTypeManager
@covers ::setTypedConfig Overrides UnitTestCase:: |
|
PaymentStatusTest:: |
public | function | @covers ::entityTypeManager | |
PaymentStatusTest:: |
public | function | @covers ::getDescription @covers ::setDescription | |
PaymentStatusTest:: |
public | function | @covers ::getParentId @covers ::setParentId | |
PaymentStatusTest:: |
public | function | @covers ::getTypedConfig | |
PaymentStatusTest:: |
public | function | @covers ::id @covers ::setId | |
PaymentStatusTest:: |
public | function | @covers ::setLabel @covers ::label | |
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. |