1. Go to this page and download the library: Download ecomdev/mysql-test-utils 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/ */
ecomdev / mysql-test-utils example snippets
use PHPUnit\Framework\TestCase;
use EcomDev\MySQLTestUtils\DatabaseFactory;
class SomeDatabaseRelatedTest extends TestCase
{
private $database;
protected function setUp() : void
{
$this->database = (new DatabaseFactory())->createDatabase();
$this->database->loadFixture('some/path/to/schema.sql');
}
public function testSomethingIsWritten()
{
$this->assertEquals(
[
['value1', 'value2']
],
$this->database->fetchTable('some_table_name', 'column1', 'column2')
);
}
}
use PHPUnit\Framework\TestCase;
use EcomDev\MySQLTestUtils\DatabaseFactory;
class SomeDatabaseRelatedTest extends TestCase
{
private static $database;
public static function setUpBeforeClass() : void
{
self::$database = (new DatabaseFactory())->createDatabase();
self::$database->loadFixture('some/path/to/schema.sql');
}
public static function tearDownAfterClass() : void
{
self::$database = null;
}
public function testSomethingIsWritten()
{
$this->assertEquals(
[
['value1', 'value2']
],
self::$database->fetchTable('some_table_name', 'column1', 'column2')
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.