Last active
November 15, 2018 10:26
-
-
Save RajithaKumara/cb2c52b0ad93fb90f7f757159211b4e4 to your computer and use it in GitHub Desktop.
Repository testing for DAO layer. Boot the kernel is required to get a valid database connection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Tests\Repository; | |
use App\Entity\User; | |
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | |
class UserRepositoryTest extends KernelTestCase | |
{ | |
/** | |
* @var \Doctrine\ORM\EntityManager | |
*/ | |
private $entityManager; | |
protected function setUp() | |
{ | |
$kernel = self::bootKernel(); | |
$this->entityManager = $kernel->getContainer() | |
->get('doctrine') | |
->getManager(); | |
} | |
public function testUserFindAll() | |
{ | |
$users = $this->entityManager | |
->getRepository(User::class) | |
->findAll() | |
; | |
// compare asserts | |
//$this->assertCount(10, $users); | |
$this->assertTrue(true); | |
} | |
protected function tearDown() | |
{ | |
parent::tearDown(); | |
$this->entityManager->close(); | |
$this->entityManager = null; // avoid memory leaks | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment