Skip to content

yireo/Yireo_MagewireTestUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Yireo MagewireTestUtils

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);
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages