protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (is_file($dbFile = __DIR__ . '/../../../../res/test_database.sqlite')) {
         unlink($dbFile);
     }
     $em = TestUtils::createTestEntityManager();
     $tool = new SchemaTool($em);
     $tool->createSchema($em->getMetadataFactory()->getAllMetadata());
     $analyzer = Analyzer::create($em, PassConfig::createForTypeScanning());
     $packageScanner = new PackageScanner($analyzer);
     $packageScanner->setLogger(new OutputLogger($output, $input->getOption('verbose')));
     $package = new Package('PHP');
     $packageVersion = $package->createVersion('5.3');
     $packageVersion->setUuid(uniqid(mt_rand(), true));
     $packageScanner->scanDirectory($packageVersion, __DIR__ . '/../../../../res/php-5.3-core-api');
     $output->writeln('Files scanned.');
     $output->write('Persisting results... ');
     $em->persist($package);
     $em->flush();
     $output->writeln('Done');
 }
 protected function setUp()
 {
     $this->em = $this->getEntityManager();
     $this->provider = new EntityTypeProvider($this->em);
     $this->typeRegistry = new TypeRegistry($this->provider);
     $this->package = new Package('foo');
     $this->versionA = $this->package->createVersion('1.0');
     $this->versionB = $this->package->createVersion('1.1');
     $this->versionC = $this->package->createVersion('1.2');
     $this->em->persist($this->package);
     $this->em->flush();
 }
 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();
 }
 protected function setUp()
 {
     $this->typeRegistry = new TypeRegistry();
     $this->em = TestUtils::createTestEntityManager(true);
     $con = $this->em->getConnection();
     $paramPersister = new ParameterPersister($con);
     $callSitePersister = new CallSitePersister($con, new ArgumentPersister($con));
     $this->persister = new PackageVersionPersister($con, new MethodContainerPersister($con, new MethodPersister($con, $paramPersister, $callSitePersister), new PropertyPersister($con), new ConstantPersister($con)), new FunctionPersister($con, $paramPersister, $callSitePersister), new GlobalConstantPersister($con));
     $package = new Package('foo');
     $this->packageVersion = $package->createVersion('1.0');
     $this->em->persist($package);
     $this->em->flush();
 }
 public function testHasVersion()
 {
     $p = new Package('foo');
     $p->createVersion('1', 'asdf');
     $this->assertTrue($p->hasVersion('1'));
     $this->assertTrue($p->hasVersion('1', 'asdf'));
     $this->assertTrue($p->hasVersion('1', 'asdf', 'foo'));
     $this->assertFalse($p->hasVersion('2'));
     $this->assertFalse($p->hasVersion('1', 'foo'));
     $p->createVersion('2', 'asdf', 'foo');
     $this->assertTrue($p->hasVersion('2', 'asdf'));
     $this->assertTrue($p->hasVersion('2', 'asdf', 'foo'));
     $this->assertFalse($p->hasVersion('2', 'asdf', 'bar'));
 }