/** * @inheritdoc */ protected function setUp() { parent::setUp(); $this->client = $this->createClient(['debug' => false]); $container = static::$kernel->getContainer(); /** @var EntityManagerInterface[] $managers */ $managers = $container->get('doctrine')->getManagers(); foreach ($managers as $manager) { $metadata = $manager->getMetadataFactory()->getAllMetadata(); if (!empty($metadata)) { $tool = new SchemaTool($manager); $tool->dropSchema($metadata); $tool->createSchema($metadata); } } $class = $container->getParameter('tree_house.keystone.model.user.class'); $salt = uniqid(); /** @var UserInterface $user */ $user = new $class(); $user->setEnabled(true); $user->setUsername('test'); $user->addRole('ROLE_USER'); $user->setSalt($salt); /** @var EncoderFactoryInterface $encoder */ $encoder = $container->get('security.encoder_factory'); $password = $encoder->getEncoder($class)->encodePassword(static::$password, $user->getSalt()); $user->setPassword($password); /** @var ManagerRegistry $doctrine */ $doctrine = static::$kernel->getContainer()->get('doctrine'); $manager = $doctrine->getManagerForClass($class); $manager->persist($user); $manager->flush($user); $manager->refresh($user); $this->user = $user; }
public function setUp() { parent::setUp(); $this->client = $this->createClient(); $this->doctrine = $this->client->getContainer()->get('doctrine.orm.entity_manager'); $this->fixturize($this->doctrine); }
/** * Setup test. * @return null */ public function setUp() { $this->app = new \AppKernel('test', true); $this->app->boot(); $this->container = $this->app->getContainer(); parent::setUp(); }
public function setUp() { parent::setUp(); $kernel = static::createKernel(); $kernel->boot(); $this->dm = $kernel->getContainer()->get('doctrine_mongodb')->getManager(); }
protected function setUp() { parent::setUp(); self::$kernel = static::createKernel(); self::$kernel->boot(); $this->entityManager = self::$kernel->getContainer()->get('doctrine')->getManager(); }
public function setUp() { parent::setUp(); $this->setupCallableComparator(); $this->rebuildDatabase(); $this->client = static::$application->getKernel()->getContainer()->get('test.client'); }
protected function setUp() { parent::setUp(); if (version_compare(Kernel::VERSION, '2.2.0', '<')) { $this->markTestSkipped('Does not work with Symfony2 2.1 due to a "host" parameter in the `routing.yml` file'); } }
protected function setUp() { if (!class_exists('Twig_Environment')) { $this->markTestSkipped('Twig is not available.'); } parent::setUp(); }
/** * {@inheritDoc} */ public function setUp() { parent::setUp(); $this->newClient(); $this->prepareDatabase(); $this->prepareFactories(); $this->prepareTest(); }
public function setUp() { parent::setUp(); /** @var \Symfony\Bundle\FrameworkBundle\Client client */ $this->client = static::createClient(); $this->runCommand('doctrine:database:create'); $this->runCommand('doctrine:schema:update --force'); }
/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); parent::setUp(); static::$kernel = static::createKernel(); static::$kernel->boot(); $this->em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager'); $this->ipBannedRepository = $this->em->getRepository('JdrAppBundle:IpBanned'); }
/** * {@inheritDoc} */ public function setUp() { static::$kernel = static::createKernel(); static::$kernel->boot(); $this->container = static::$kernel->getContainer(); $this->logger = $this->container->get('logger'); $this->dataModel = $this->container->get('DataModel'); parent::setUp(); }
protected function setUp() { parent::setUp(); $this->client = static::createClient(); $this->client->followRedirects(); $this->kern = $this->client->getKernel(); $this->container = $this->client->getContainer(); $this->em = $this->container->get('doctrine.orm.entity_manager'); }
public function setUp() { parent::setUp(); $this->client = static::createClient(); $this->storage = $this->client->getContainer()->get('my_drinks.recipe.storage'); $fs = new Filesystem(); $fs->remove($this->client->getContainer()->getParameter("recipes_upload_target_dir")); $this->authenticateAsAdmin(); }
public function setUp() { parent::setUp(); $this->client = static::createClient(); $this->container = $this->client->getContainer(); $this->listener = new BreadcrumbListener($this->container); $this->service = new BreadcrumbService($this->container); $this->resolver = new ControllerResolver($this->container, new ControllerNameParser(static::createKernel())); }
public function setUp() { self::bootKernel(); parent::setUp(); $gatewayClassname = 'AppBundle\\Entity\\JokeGateway'; $this->gateway = $this->prophesize($gatewayClassname); $this->factory = new JokeFactory(); $this->repository = new JokeRepository($this->gateway->reveal(), $this->factory); }
public function setUp() { parent::setUp(); $this->client = static::createClient(); $this->client->restart(); if ($this->logger === null) { $this->logger = $this->client->getContainer()->get('monolog.logger.devel'); } }
public function setUp() { if (!class_exists('Doctrine\\ORM\\EntityManager')) { $this->markTestSkipped('Doctrine ORM is not available.'); } parent::setUp(); self::createClient(); $this->container = self::$kernel->getContainer(); $this->item = $this->container->get('doctrine')->getRepository('Slad\\BookingBundle\\Tests\\Fixtures\\ORM\\Entity\\BookableItem')->findOneBy(array()); }
public function setUp() { parent::setUp(); $this->client = static::createClient(); $this->application = new Application($this->client->getKernel()); $this->application->setAutoExit(false); $this->executeCommand(new CreateDatabaseDoctrineCommand(), new ArrayInput([])); $this->executeCommand(new MigrationsMigrateDoctrineCommand(), new ArrayInput([])); $this->executeCommand(new LoadDataFixturesDoctrineCommand(), new ArrayInput([])); }
/** * Prepare each test */ public function setUp() { parent::setUp(); $this->client = static::createClient(); $this->container = $this->client->getContainer(); $this->em = $this->container->get('doctrine')->getManager(); $manipulatorService = $this->container->getParameter('crisistextline.user_profile.user_manipulator')['service']; $this->userManager = $this->container->get('fos_user.user_manager'); $this->userManipulator = $this->container->get($manipulatorService); }
public function setUp() { parent::setUp(); //HTTP client $this->client = static::createClient(); //Service container $this->container = $this->client->getContainer(); //Begin SQL transaction to rollback it $this->em = $this->container->get('doctrine.orm.default_entity_manager'); $this->em->beginTransaction(); }
public function setUp() { parent::setUp(); self::bootKernel(); $this->doctrine = self::$kernel->getContainer()->get('doctrine'); $this->client = new Client(['url' => STORAGE_API_URL, "token" => STORAGE_API_TOKEN]); $this->clearServers(); $this->clearAccounts(); $this->stopTasks(); //get the DI container self::$container = self::$kernel->getContainer(); }
protected function setUp() { parent::setUp(); static::$kernel = static::createKernel(); static::$kernel->boot(); $this->setEntityManager(self::$kernel->getContainer()->get('doctrine')->getManager()); $this->generator = new GeneratorService(); $this->generator->setAnnotationReader(new AnnotationReader()); $this->generator->setTwigEngine(self::$kernel->getContainer()->get('twig')); $this->dirWithGeneratedModels = __DIR__ . '/generated_models'; $this->predefinedModelSaver = (new ExtJSModelsSaver())->setEntityManager($this->em)->setGenerator($this->generator)->setDirToSaveGeneratedModels($this->dirWithGeneratedModels); self::$fullClassNamesList = $this->em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames(); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->manager = $this->getServiceContainer()->get('es.manager'); $this->manager->getConnection()->dropAndCreateIndex(); // There is something wrong with ElasticsearchTestCase method getDataArray, // if we don't create in here all test data, it's not existing when test is run. $content = new Pair(); $content->setId('name0'); $content->setValue('will not be here'); $this->manager->persist($content); $this->manager->commit(); }
/** * @throws \Exception */ protected function setUp() { parent::setUp(); $kernel = static::createKernel(); $kernel->boot(); $application = new Application($kernel); $application->setAutoExit(false); $options['-e'] = 'test'; $options['-q'] = null; $options['-n'] = true; $options['--purge-with-truncate'] = null; $options['--fixtures'] = __DIR__ . '/../../DataFixtures/ORM/'; $input = new ArrayInput(array_merge($options, array('command' => 'doctrine:fixtures:load'))); $result = $application->run($input); }
protected function setUp() { parent::setUp(); $client = static::createClient(); $this->container = $client->getContainer(); $this->doctrine = $this->container->get('doctrine'); $this->changeservice = $this->container->get('ibrows_loggable.changer'); $this->logservice = $this->container->get('ibrows_loggable.logger'); $this->em = $this->doctrine->getManager(); $this->mainlogrepo = $this->doctrine->getManagerForClass($this->abstractTestClass)->getRepository($this->abstractTestClass); $this->logrepo = $this->doctrine->getManagerForClass($this->testClass)->getRepository($this->testClass); $this->logrepoParent = $this->doctrine->getManagerForClass($this->testClass)->getRepository($this->testClassParent); $this->logrepoMany = $this->doctrine->getManagerForClass($this->testClass)->getRepository($this->testClassMany); $this->cleanDB(); }
public function setUp() { static::$kernel = static::createKernel(); static::$kernel->boot(); $this->application = new Application(static::$kernel); // drop the database $command = new DropDatabaseDoctrineCommand(); $this->application->add($command); $input = new ArrayInput(['command' => 'doctrine:database:drop', '--force' => true]); $command->run($input, new NullOutput()); // we have to close the connection after dropping the database so we don't get "No database selected" error $connection = $this->application->getKernel()->getContainer()->get('doctrine')->getConnection(); if ($connection->isConnected()) { $connection->close(); } // create the database $command = new CreateDatabaseDoctrineCommand(); $this->application->add($command); $input = new ArrayInput(['command' => 'doctrine:database:create']); $command->run($input, new NullOutput()); // create schema $command = new CreateSchemaDoctrineCommand(); $this->application->add($command); $input = new ArrayInput(['command' => 'doctrine:schema:create']); $command->run($input, new NullOutput()); // get the Entity Manager $this->em = static::$kernel->getContainer()->get('doctrine')->getManager(); // load fixtures // not work // $client = static::createClient(); // $loader = new ContainerAwareLoader($client->getContainer()); // $loader->loadFromDirectory(static::$kernel->locateResource('@Art\JobtestBundle\DataFixtures\ORM')); // // $purger = new ORMPurger($this->em); // $executor = new ORMExecutor($this->em, $purger); // $executor->execute($loader->getFixtures()); $loader = new Loader(); $loader->addFixture(new LoadCategoryData()); $loader->addFixture(new LoadJobData()); $loader->addFixture(new LoadAffiliateData()); $userFixture = new LoadUserData(); $userFixture->setContainer(static::$kernel->getContainer()); $loader->addFixture($userFixture); $purger = new ORMPurger($this->em); $executor = new ORMExecutor($this->em, $purger); $executor->execute($loader->getFixtures()); parent::setUp(); }
protected function setUp() { if (!class_exists('Twig_Environment')) { $this->markTestSkipped('Twig is not available.'); } if (null === $this->em) { $this->em = $this->client->getContainer()->get('doctrine')->getManager(); if (!static::$schemaSetUp) { $st = new SchemaTool($this->em); $classes = $this->em->getMetadataFactory()->getAllMetadata(); $st->dropSchema($classes); $st->createSchema($classes); static::$schemaSetUp = true; } } parent::setUp(); }
/** Temporary substitute for setting up * proper test fixtures */ public function setUp() { parent::setUp(); self::bootKernel(); $this->em = static::$kernel->getContainer()->get('doctrine')->getManager(); $product = new ProductApi(); $product->setName('First product'); $product->setPrice(1.22); $this->em->persist($product); $product2 = new ProductApi(); $product2->setName('Second product'); $product2->setPrice(2.11); $this->em->persist($product2); $this->em->flush(); $this->product1 = $product; $this->product2 = $product2; }
public function setUp() { parent::setUp(); static::$kernel = static::createKernel(array()); static::$kernel->boot(); $this->fixtures = array(); $annotations = $this->getAnnotations(); if (isset($annotations['method']['dataset'])) { $dataset_classes = $annotations['method']['dataset']; foreach ($dataset_classes as $dataset_class) { $fixture = new $dataset_class(); if (!$fixture instanceof FixtureInterface) { continue; } $this->fixtures[] = $fixture; } } static::assertNotNull(static::$kernel->getContainer()); $this->loadTestData($this->fixtures); }