class PaymentExecuteAccessTest in Payment 8.2
@coversDefaultClass \Drupal\payment\Event\PaymentExecuteAccess
@group Payment
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\payment\Unit\Event\PaymentExecuteAccessTest
Expanded class hierarchy of PaymentExecuteAccessTest
File
- tests/
src/ Unit/ Event/ PaymentExecuteAccessTest.php, line 19
Namespace
Drupal\Tests\payment\Unit\EventView source
class PaymentExecuteAccessTest extends UnitTestCase {
/**
* The account to check access for.
*
* @var \Drupal\payment\Entity\PaymentInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $account;
/**
* The event under test.
*
* @var \Drupal\payment\Event\PaymentExecuteAccess
*/
protected $sut;
/**
* The payment.
*
* @var \Drupal\payment\Entity\PaymentInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $payment;
/**
* The payment method.
*
* @var \Drupal\payment\Plugin\Payment\Method\PaymentMethodInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $paymentMethod;
/**
* {@inheritdoc}
*/
public function setUp() : void {
$this->account = $this
->createMock(AccountInterface::class);
$this->payment = $this
->createMock(PaymentInterface::class);
$this->paymentMethod = $this
->createMock(PaymentMethodInterface::class);
$this->sut = new PaymentExecuteAccess($this->payment, $this->paymentMethod, $this->account);
}
/**
* @covers ::getAccount
*/
public function testGetAccount() {
$this
->assertSame($this->account, $this->sut
->getAccount());
}
/**
* @covers ::getPayment
*/
public function testGetPayment() {
$this
->assertSame($this->payment, $this->sut
->getPayment());
}
/**
* @covers ::getPaymentMethod
*/
public function testGetPaymentMethod() {
$this
->assertSame($this->paymentMethod, $this->sut
->getPaymentMethod());
}
/**
* @covers ::getAccessResult
* @covers ::setAccessResult
*/
public function testGetAccessResultAllowed() {
$result = new AccessResultAllowed();
$this
->assertSame($this->sut, $this->sut
->setAccessResult($result));
$this
->assertTrue($this->sut
->getAccessResult()
->isAllowed());
}
/**
* @covers ::getAccessResult
* @covers ::setAccessResult
*/
public function testGetAccessResultForbidden() {
$result = new AccessResultForbidden();
$this
->assertSame($this->sut, $this->sut
->setAccessResult($result));
$this
->assertFalse($this->sut
->getAccessResult()
->isAllowed());
}
/**
* @covers ::getAccessResult
* @covers ::setAccessResult
*/
public function testGetAccessResultNeutral() {
$result = new AccessResultNeutral();
$this
->assertSame($this->sut, $this->sut
->setAccessResult($result));
$this
->assertTrue($this->sut
->getAccessResult()
->isAllowed());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PaymentExecuteAccessTest:: |
protected | property | The account to check access for. | |
PaymentExecuteAccessTest:: |
protected | property | The payment. | |
PaymentExecuteAccessTest:: |
protected | property | The payment method. | |
PaymentExecuteAccessTest:: |
protected | property | The event under test. | |
PaymentExecuteAccessTest:: |
public | function |
Overrides UnitTestCase:: |
|
PaymentExecuteAccessTest:: |
public | function | @covers ::getAccessResult @covers ::setAccessResult | |
PaymentExecuteAccessTest:: |
public | function | @covers ::getAccessResult @covers ::setAccessResult | |
PaymentExecuteAccessTest:: |
public | function | @covers ::getAccessResult @covers ::setAccessResult | |
PaymentExecuteAccessTest:: |
public | function | @covers ::getAccount | |
PaymentExecuteAccessTest:: |
public | function | @covers ::getPayment | |
PaymentExecuteAccessTest:: |
public | function | @covers ::getPaymentMethod | |
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. |