PHP code example of matthiasnoback / doctrine-orm-test-service-provider

1. Go to this page and download the library: Download matthiasnoback/doctrine-orm-test-service-provider 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/ */

    

matthiasnoback / doctrine-orm-test-service-provider example snippets




use PHPUnit\Framework\TestCase;
use Noback\PHPUnitTestServiceContainer\PHPUnit\TestCaseWithEntityManager;

class StorageTest extends TestCase 
{
    use TestCaseWithEntityManager;
    
    protected function getEntityDirectories(): array
    {
        return array(
            __DIR__ . '/Entity'
        );
    }

    /**
     * @test
     */
    public function it_persists_an_entity()
    {
        $user = new User();
        $user->setName('Matthias');

        $this->getEntityManager()->persist($user);
        $this->getEntityManager()->flush();
    }
}