|
7 | 7 |
|
8 | 8 | namespace Magento\SalesRule\Controller\Adminhtml\Promo\Quote; |
9 | 9 |
|
10 | | -use Magento\TestFramework\Helper\Bootstrap; |
11 | 10 | use Magento\TestFramework\TestCase\AbstractBackendController; |
12 | 11 |
|
13 | 12 | /** |
14 | 13 | * New action html test |
| 14 | + * |
| 15 | + * @magentoAppArea adminhtml |
15 | 16 | */ |
16 | 17 | class NewActionHtmlTest extends AbstractBackendController |
17 | 18 | { |
| 19 | + /** |
| 20 | + * @var string |
| 21 | + */ |
| 22 | + protected $resource = 'Magento_SalesRule::quote'; |
| 23 | + |
| 24 | + /** |
| 25 | + * @var string |
| 26 | + */ |
| 27 | + protected $uri = 'backend/sales_rule/promo_quote/newActionHtml'; |
| 28 | + |
| 29 | + /** |
| 30 | + * @var string |
| 31 | + */ |
| 32 | + private $formName = 'test_form'; |
| 33 | + |
18 | 34 | /** |
19 | 35 | * Test verifies that execute method has the proper data-form-part value in html response |
20 | 36 | * |
21 | 37 | * @return void |
22 | 38 | */ |
23 | 39 | public function testExecute(): void |
24 | 40 | { |
25 | | - $formName = 'test_form'; |
| 41 | + $this->prepareRequest(); |
| 42 | + $this->dispatch($this->uri); |
| 43 | + $html = $this->getResponse() |
| 44 | + ->getBody(); |
| 45 | + $this->assertContains($this->formName, $html); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @inheritdoc |
| 50 | + */ |
| 51 | + public function testAclHasAccess() |
| 52 | + { |
| 53 | + $this->prepareRequest(); |
| 54 | + parent::testAclHasAccess(); |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * @inheritdoc |
| 59 | + */ |
| 60 | + public function testAclNoAccess() |
| 61 | + { |
| 62 | + $this->prepareRequest(); |
| 63 | + parent::testAclNoAccess(); |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * Prepare request |
| 68 | + * |
| 69 | + * @return void |
| 70 | + */ |
| 71 | + private function prepareRequest(): void |
| 72 | + { |
26 | 73 | $this->getRequest()->setParams( |
27 | 74 | [ |
28 | 75 | 'id' => 1, |
29 | | - 'form_namespace' => $formName, |
| 76 | + 'form_namespace' => $this->formName, |
30 | 77 | 'type' => 'Magento\SalesRule\Model\Rule\Condition\Product|quote_item_price', |
31 | 78 | ] |
32 | | - ); |
33 | | - $objectManager = Bootstrap::getObjectManager(); |
34 | | - /** @var NewActionHtml $controller */ |
35 | | - $controller = $objectManager->create(NewActionHtml::class); |
36 | | - $controller->execute(); |
37 | | - $html = $this->getResponse() |
38 | | - ->getBody(); |
39 | | - $this->assertContains($formName, $html); |
| 79 | + )->setMethod('POST'); |
40 | 80 | } |
41 | 81 | } |
0 commit comments