yireo / magento2-magewire-test-utils
Testing utilities to test for Magewire components in Magento 2
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Type:magento2-library
Requires
- magento/framework: ^103.0
- magewirephp/magewire: ^1.0
- yireo/magento2-integration-test-helper: ~0.0.11
This package is auto-updated.
Last update: 2024-11-07 08:24:51 UTC
README
A library of testing utilities (among which PHPUnit assertions) for building integration tests for Magewire-driven Magento extensions
Current status: Draft
Installation
composer require yireo/magento2-magewire-test-utils
Usage
Extend your own integration test case from MagewireComponentTestCase
:
namespace Yireo\Example\Test\Integration\Magewire; use Magento\Framework\App\Response\Http; use Yireo\IntegrationTestHelper\Test\Integration\Traits\AssertModuleIsEnabled; use Yireo\MagewireTestUtils\Test\Integration\MagewireComponentTestCase; use Yireo\Example\Magewire\MyExample; class MyExampleTest extends MagewireComponentTestCase { use AssertModuleIsEnabled; /** * @return void * @magentoAppArea frontend */ public function testComponentResponse() { $this->assertModuleIsEnabled('Yireo_Example'); $this->assertModuleIsEnabled('Magewirephp_Magewire'); $this->assertMagewireComponentResolves( 'content_schedule_block0', MyExample::class, ['cms_index_index'] ); $this->dispatch('/'); /** @var Http $response */ $response = $this->getResponse(); $body = $response->getBody(); $this->assertMagewireBlockExistsInHtml('content_schedule_block0', $body); } }