|
3 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
| 6 | +declare(strict_types=1); |
| 7 | + |
6 | 8 | namespace Magento\TaxImportExport\Block\Adminhtml\Rate;
|
7 | 9 |
|
8 |
| -class ImportExportTest extends \PHPUnit\Framework\TestCase |
| 10 | +use Magento\Framework\ObjectManagerInterface; |
| 11 | +use Magento\Framework\View\LayoutInterface; |
| 12 | +use Magento\TestFramework\Helper\Bootstrap; |
| 13 | +use PHPUnit\Framework\TestCase; |
| 14 | + |
| 15 | +/** |
| 16 | + * Tests for Tax Rate Import/Export form. |
| 17 | + * |
| 18 | + * @magentoAppArea adminhtml |
| 19 | + */ |
| 20 | +class ImportExportTest extends TestCase |
9 | 21 | {
|
10 | 22 | /**
|
11 |
| - * @var \Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport |
| 23 | + * @var ObjectManagerInterface |
12 | 24 | */
|
13 |
| - protected $_block = null; |
| 25 | + private $objectManager; |
14 | 26 |
|
| 27 | + /** |
| 28 | + * @var ImportExport |
| 29 | + */ |
| 30 | + protected $block = null; |
| 31 | + |
| 32 | + /** |
| 33 | + * @inheritdoc |
| 34 | + */ |
15 | 35 | protected function setUp(): void
|
16 | 36 | {
|
17 |
| - \Magento\TestFramework\Helper\Bootstrap::getInstance() |
18 |
| - ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); |
19 |
| - $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( |
20 |
| - \Magento\Framework\View\LayoutInterface::class |
21 |
| - )->createBlock(\Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport::class); |
| 37 | + $this->objectManager = Bootstrap::getObjectManager(); |
| 38 | + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(ImportExport::class); |
22 | 39 | }
|
23 | 40 |
|
| 41 | + /** |
| 42 | + * @inheritdoc |
| 43 | + */ |
24 | 44 | protected function tearDown(): void
|
25 | 45 | {
|
26 |
| - $this->_block = null; |
| 46 | + $this->block = null; |
27 | 47 | }
|
28 | 48 |
|
29 |
| - public function testCreateBlock() |
| 49 | + /** |
| 50 | + * @return void |
| 51 | + */ |
| 52 | + public function testCreateBlock(): void |
30 | 53 | {
|
31 |
| - $this->assertInstanceOf(\Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport::class, $this->_block); |
| 54 | + $this->assertInstanceOf(ImportExport::class, $this->block); |
32 | 55 | }
|
33 | 56 |
|
34 |
| - public function testFormExists() |
| 57 | + /** |
| 58 | + * @return void |
| 59 | + */ |
| 60 | + public function testFormExists(): void |
35 | 61 | {
|
36 |
| - $html = $this->_block->toHtml(); |
37 |
| - |
| 62 | + $html = $this->block->toHtml(); |
38 | 63 | $this->assertStringContainsString('<form id="import-form"', $html);
|
| 64 | + $this->assertStringContainsString('<form id="export_form"', $html); |
| 65 | + } |
39 | 66 |
|
| 67 | + /** |
| 68 | + * @return void |
| 69 | + */ |
| 70 | + public function testExportFormButtonOnClick(): void |
| 71 | + { |
| 72 | + $html = $this->block->toHtml(); |
40 | 73 | $this->assertStringContainsString('<form id="export_form"', $html);
|
| 74 | + $this->assertStringContainsString('export_form.submit();', $html); |
41 | 75 | }
|
42 | 76 | }
|
0 commit comments