PHP code example of webgriffe / functional-test-trait

1. Go to this page and download the library: Download webgriffe/functional-test-trait library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webgriffe / functional-test-trait example snippets



	
class HomepageTest extends EcomDev_PHPUnit_Test_Case_Controller
{
    use Webgriffe_FunctionalTest_Trait;
	
    /**
     * @loadFixture category.yaml
     */
    public function testHome()
    {
        $client = self::createClient();
        $crawler = $client->request('GET', '/');
	
        $this->assertTrue($client->getResponse()->isSuccessful());
        $this->assertContains('Default welcome msg!', $crawler->filter('div.welcome-msg')->text());
        $this->assertCount(1, $crawler->filter('ul.nav.mega-menu'));
        $categoryLink = $crawler->filter('ul.nav.mega-menu')->filter('li')->eq(0)->filter('a');
        $this->assertCount(1, $categoryLink);
        $this->assertContains('My Category', $categoryLink->text());
	
        $crawler = $client->click($categoryLink->link());
	
        $this->assertTrue($client->getResponse()->isSuccessful());
        $this->assertContains('My Category', $crawler->filter('div.page-title h1')->text());
    }
}

$secondaryWebsite = Mage::app()->getWebsite('otherwebsite');
$client = self::createClient($secondaryWebsite);

$client = self::createClient(true);

$client = self::createClient();
$client->request('GET', '/');
self::openResponseInBrowser($client)

$staticFilesClient = self::createClient(null, false, 'test', 'get.php');
$staticFilesClient->request('GET', '/path/to/media/file.jpg');
xml
<testsuite name="My Project Functional Test Suite">
    <directory suffix="Test.php">tests</directory>
</testsuite>
xml
<php>
    <server name="MAGE_ENVIRONMENT" value="test" />
</php>