PHP code example of airmedia / phpunit-doctrine-extension
1. Go to this page and download the library: Download airmedia/phpunit-doctrine-extension 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/ */
airmedia / phpunit-doctrine-extension example snippets
use AirMedia\Test\ORMTestCase;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\ORM\Configuration;
use Ramsey\Uuid\Doctrine\UuidType;
class RepositoryTestCase extends ORMTestCase
{
static protected $customTypes = [
UuidType::NAME => UuidType::class,
];
public function testAnything()
{
$repository = $this->em->getRepository('Acme\Entity\User');
// Action and asserts...
}
protected function createMappingDriver(Configuration $config): MappingDriver
{
$annotationDriver = $config->newDefaultAnnotationDriver([
realpath(__DIR__ . '/../src/Entity'),
], false);
$driver = new MappingDriverChain();
$driver->addDriver($annotationDriver, 'Acme\Entity');
return $driver;
}
}
use AirMedia\Test\ORMTestCase;
use AirMedia\Test\Helper\DataFixturesTrait;
class FooTestCase extends ORMTestCase
{
use DataFixturesTrait;
protected function setUp()
{
parent::setUp();
$this->loadFixtures([
new \Acme\DataFixtures\UserFixture(),
'Acme\DataFixtures\GroupFixture', // or class name
]);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.