function PaymentTestPaymentMethodEntityPermissionWebTestCase::testPaymentMethodEntityPermissions in Payment 7
File
- tests/
payment_test/ tests/ PaymentTestPaymentMethodEntityPermissionWebTestCase.test, line 29 - Contains class PaymentTestPaymentMethodEntityPermissionWebTestCase.
Class
- PaymentTestPaymentMethodEntityPermissionWebTestCase
- Tests payment_method entity permissions.
Code
function testPaymentMethodEntityPermissions() {
// Create a new payment method.
$this
->assertEntityPermission($this
->paymentMethodCreate(0, payment_method_controller_load('PaymentMethodBasicController')), 'payment method', 'payment_method_access', 'create', array(
'payment.payment_method.create.PaymentMethodBasicController',
));
// Update a payment method that belongs to user 1.
$this
->assertEntityPermission($this
->paymentMethodCreate(1, payment_method_controller_load('PaymentMethodBasicController')), 'payment method', 'payment_method_access', 'update', array(
'payment.payment_method.update.any',
));
// Update a payment method that belongs to user 2.
$this
->assertEntityPermission($this
->paymentMethodCreate(2, payment_method_controller_load('PaymentMethodBasicController')), 'payment method', 'payment_method_access', 'update', array(
'payment.payment_method.update.own',
));
// Delete a payment method that belongs to user 1.
$this
->assertEntityPermission($this
->paymentMethodCreate(1, payment_method_controller_load('PaymentMethodBasicController')), 'payment method', 'payment_method_access', 'delete', array(
'payment.payment_method.delete.any',
));
// Delete a payment method that belongs to user 2.
$this
->assertEntityPermission($this
->paymentMethodCreate(2, payment_method_controller_load('PaymentMethodBasicController')), 'payment method', 'payment_method_access', 'delete', array(
'payment.payment_method.delete.own',
));
// Enable an enabled payment method that belongs to user 1.
$payment_method = $this
->paymentMethodCreate(1, payment_method_controller_load('PaymentMethodBasicController'));
$this
->assertEntityPermission($payment_method, 'enabled payment method', 'payment_method_access', 'enable', array(
'payment.payment_method.update.any',
), array(
'root' => FALSE,
'authenticated_with_permissions' => FALSE,
));
// Enable an enabled payment method that belongs to user 2.
$payment_method = $this
->paymentMethodCreate(2, payment_method_controller_load('PaymentMethodBasicController'));
$this
->assertEntityPermission($payment_method, 'enabled payment method', 'payment_method_access', 'enable', array(
'payment.payment_method.update.own',
), array(
'root' => FALSE,
'authenticated_with_permissions' => FALSE,
));
// Enable a disabled payment method that belongs to user 1.
$payment_method = $this
->paymentMethodCreate(1, payment_method_controller_load('PaymentMethodBasicController'));
$payment_method->enabled = FALSE;
$this
->assertEntityPermission($payment_method, 'disabled payment method', 'payment_method_access', 'enable', array(
'payment.payment_method.update.any',
));
// Enable a disabled payment method that belongs to user 2.
$payment_method = $this
->paymentMethodCreate(2, payment_method_controller_load('PaymentMethodBasicController'));
$payment_method->enabled = FALSE;
$this
->assertEntityPermission($payment_method, 'disabled payment method', 'payment_method_access', 'enable', array(
'payment.payment_method.update.own',
));
// Disable a disabled payment method that belongs to user 1.
$payment_method = $this
->paymentMethodCreate(1, payment_method_controller_load('PaymentMethodBasicController'));
$payment_method->enabled = FALSE;
$this
->assertEntityPermission($payment_method, 'disabled payment method', 'payment_method_access', 'disable', array(
'payment.payment_method.update.any',
), array(
'root' => FALSE,
'authenticated_with_permissions' => FALSE,
));
// Disable a disabled payment method that belongs to user 2.
$payment_method = $this
->paymentMethodCreate(2, payment_method_controller_load('PaymentMethodBasicController'));
$payment_method->enabled = FALSE;
$this
->assertEntityPermission($payment_method, 'disabled payment method', 'payment_method_access', 'disable', array(
'payment.payment_method.update.own',
), array(
'root' => FALSE,
'authenticated_with_permissions' => FALSE,
));
// Disable an enabled payment method that belongs to user 1.
$payment_method = $this
->paymentMethodCreate(1, payment_method_controller_load('PaymentMethodBasicController'));
$this
->assertEntityPermission($payment_method, 'disabled payment method', 'payment_method_access', 'disable', array(
'payment.payment_method.update.any',
));
// Enable am enabled payment method that belongs to user 2.
$payment_method = $this
->paymentMethodCreate(2, payment_method_controller_load('PaymentMethodBasicController'));
$this
->assertEntityPermission($payment_method, 'disabled payment method', 'payment_method_access', 'disable', array(
'payment.payment_method.update.own',
));
// Clone a payment method that belongs to user 1.
$this
->assertEntityPermission($this
->paymentMethodCreate(1, payment_method_controller_load('PaymentMethodBasicController')), 'payment method', 'payment_method_access', 'clone', array(
'payment.payment_method.view.any',
'payment.payment_method.create.PaymentMethodBasicController',
));
// Clone a payment method that belongs to user 2.
$this
->assertEntityPermission($this
->paymentMethodCreate(2, payment_method_controller_load('PaymentMethodBasicController')), 'payment method', 'payment_method_access', 'clone', array(
'payment.payment_method.view.own',
'payment.payment_method.create.PaymentMethodBasicController',
));
// View a payment method that belongs to user 1.
$this
->assertEntityPermission($this
->paymentMethodCreate(1, payment_method_controller_load('PaymentMethodBasicController')), 'payment method', 'payment_method_access', 'view', array(
'payment.payment_method.view.any',
));
// View a payment method that belongs to user 2.
$this
->assertEntityPermission($this
->paymentMethodCreate(2, payment_method_controller_load('PaymentMethodBasicController')), 'payment method', 'payment_method_access', 'view', array(
'payment.payment_method.view.own',
));
}