protected function getEntityManager() { if (!isset($_SERVER['MYSQL_USER']) || !isset($_SERVER['MYSQL_HOST']) || !isset($_SERVER['MYSQL_PASSWORD']) || !isset($_SERVER['MYSQL_DATABASE'])) { $this->markTestSkipped('You need to configure a MySQL database, see phpunit.dist.xml'); } return TestUtils::createMysqlTestEntityManager($_SERVER['MYSQL_USER'], $_SERVER['MYSQL_PASSWORD'], $_SERVER['MYSQL_DATABASE'], $_SERVER['MYSQL_HOST']); }
protected function setUp() { if (!isset($_SERVER['MYSQL_USER']) || !isset($_SERVER['MYSQL_HOST']) || !isset($_SERVER['MYSQL_PASSWORD']) || !isset($_SERVER['MYSQL_DATABASE'])) { $this->markTestSkipped('You need to configure a MySQL database, see phpunit.dist.xml'); } $this->em = TestUtils::createMysqlTestEntityManager($_SERVER['MYSQL_USER'], $_SERVER['MYSQL_PASSWORD'], $_SERVER['MYSQL_DATABASE'], $_SERVER['MYSQL_HOST']); $this->repo = $this->em->getRepository('Scrutinizer\\PhpAnalyzer\\Model\\Package'); $this->typeProvider = new EntityTypeProvider($this->em); $this->typeRegistry = new TypeRegistry($this->typeProvider); $this->package = new Package('foo'); $this->packageVersion = $this->package->createVersion('1.0'); $this->packageVersion->setAttribute('dir', __DIR__); $this->em->persist($this->package); $this->otherPackage = new Package('bar'); $this->otherPackageVersion = $this->otherPackage->createVersion('0.1'); $this->otherPackageVersion->setAttribute('dir', __DIR__); $this->em->persist($this->otherPackage); $this->em->flush(); }