public function setUp() { parent::setUp(); $this->app->get('/exception', function () { throw new IAmATeaPodException(); })->bind('exception'); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->clearTestingCache(); $this->app['hc.api_registry']->install('__oauthId__', '__oauthSecret__', 963852); $this->app['hc.api_registry']->updateCreds('__oauthId__', '__oauthSecret__', '__authToken__', new \DateTime('+1 hour')); }
/** {@inheritdoc} */ public function setUp() { parent::setUp(); $this->client = $this->createClient(); $this->books = new LocalBookRepository(); $this->reservations = new LocalReservationRepository(); $this->clearDatabase(); }
public function setUp() { parent::setUp(); if ($this->client === null) { $this->client = $this->createClient(); } $this->client->followRedirects(); }
public function setUp() { parent::setUp(); $this->app->get('/closure', function () { return []; }); // This only works with full qualified namespaces! In this case we dont use a namespace $this->app->get('/namespace', sprintf('%s::dummyAction', DummyController::class)); $this->app->get('/service', 'dummy.controller:dummyAction'); }
public function setUp() { parent::setUp(); if ($this->client == null) { if (self::$server == null) { self::$server = static::createClient(); } $this->client = self::$server; } }
public function setUp() { parent::setUp(); $this->app->get('/redirect', function () { return new RedirectRoute('dummy'); })->bind('redirectTo'); $this->app->get('/dummy', function () { return new Response(); })->bind('dummy'); }
/** * Applicaiton を生成しトランザクションを開始する. */ public function setUp() { parent::setUp(); if ($this->isSqliteInMemory()) { $this->initializeDatabase(); } if (isset($this->app['orm.em'])) { $this->app['orm.em']->getConnection()->beginTransaction(); } }
/** * Applicaiton を生成しトランザクションを開始する. */ public function setUp() { parent::setUp(); // in the case of sqlite in-memory database only. if (array_key_exists('memory', $this->app['config']['database']) && $this->app['config']['database']['memory']) { $this->initializeDatabase(); } if (isset($this->app['orm.em'])) { $this->app['orm.em']->getConnection()->beginTransaction(); } }
public function setUp() { parent::setUp(); $this->app->boot(); $this->app['session.storage'] = new MockArraySessionStorage(); /** @var Database $db */ $db = $this->app['mongodb.database']; $db->selectCollection('gateway_configs')->deleteMany([]); $db->selectCollection('security_tokens')->deleteMany([]); $db->selectCollection('payments')->deleteMany([]); }
public function setUp() { parent::setUp(); exec(__DIR__ . '/../vendor/bin/phinx migrate -e testing'); $item = Model::factory('Todo\\Model\\Item'); $item->delete_many(); ORM::for_table('SQLITE_SEQUENCE')->raw_execute("delete from SQLITE_SEQUENCE where name='item';"); $item->create(); $item->title = 'Test title'; $item->done = false; $item->save(); }
public function setUp() { parent::setUp(); $this->client = static::createClient(); // $this->client->followRedirects(); $this->dataInsertUser = array(array('name' => 'anhnguyen', 'password' => '1234', 'fullname' => 'Nguyễn Thế Anh', 'sex' => 1, 'created_Time' => date("Y-m-d H:i:s"), 'updated_Time' => date("Y-m-d H:i:s"))); $id = ''; foreach ($this->dataInsertUser as $dataUser) { $id = $this->app['user.service']->insert($dataUser); } $this->dataInsertUser[0]['id'] = $id; }
public function setUp() { parent::setUp(); // set user $user = array("email" => "*****@*****.**", "password" => "f71dbe52628a3f83a77ab494817525c6"); $this->app['user_service']->create($user); // set pictures $item1 = array("id" => "354", "file" => "2013_05_26_3561.JPG", "description" => "Bienvenue Alice !", "date" => "2013-05-26 17:04:17", "like" => "0", "ratio" => "1.499531", "reverseRatio" => "0.666875", "type" => "picture"); $item2 = array("id" => "334", "file" => "2013_05_19_3325.JPG", "description" => "La East side galerie", "date" => "2013-05-19 11:02:09", "like" => "0", "ratio" => "1.392515", "reverseRatio" => "0.718125", "type" => "picture"); $this->app['picture_service']->insert($item1); $this->app['picture_service']->insert($item2); }
public function setUp() { parent::setUp(); // truncate tables $this->app['orm.em']->getConnection()->query('START TRANSACTION; SET FOREIGN_KEY_CHECKS=0; TRUNCATE user; TRUNCATE account; TRUNCATE account_transaction; TRUNCATE currency; SET FOREIGN_KEY_CHECKS=1; COMMIT;'); // Run fixtures to populate database $loader = new DataLoader(); $loader->load($this->app['orm.em']); }
public function setUp() { parent::setUp(); if ($this->app['config']['database']['driver'] == 'pdo_sqlite') { // Connection が別物になってしまうため $this->markTestSkipped('Can not support for sqlite3'); } $c = $this->app['controllers_factory']; $c->match('/tran1', '\\Eccube\\Tests\\Transaction\\TransactionControllerMock::tran1')->bind('tran1'); $c->match('/tran2', '\\Eccube\\Tests\\Transaction\\TransactionControllerMock::tran2')->bind('tran2'); $c->match('/tran3', '\\Eccube\\Tests\\Transaction\\TransactionControllerMock::tran3')->bind('tran3'); $c->match('/tran4', '\\Eccube\\Tests\\Transaction\\TransactionControllerMock::tran4')->bind('tran4'); $c->match('/tran5', '\\Eccube\\Tests\\Transaction\\TransactionControllerMock::tran5')->bind('tran5'); $c->match('/tran6', '\\Eccube\\Tests\\Transaction\\TransactionControllerMock::tran6')->bind('tran6'); $c->match('/tran7', '\\Eccube\\Tests\\Transaction\\TransactionControllerMock::tran7')->bind('tran7'); $c->match('/tran8', '\\Eccube\\Tests\\Transaction\\TransactionControllerMock::tran8')->bind('tran8'); $c->match('/tran9', '\\Eccube\\Tests\\Transaction\\TransactionControllerMock::tran9')->bind('tran9'); $this->app->mount('', $c); }
public function setUp() { parent::setUp(); $this->app->get('/flash', function (Flash $flashBag) { $flashBag->add('error', 'flashy'); return new Response('flash added'); }); $this->app->get('/security', function (TokenContext $context) { if ($context->hasNonAnonymousToken()) { $userName = $context->getCurrentUser()->getUsername(); return new Response(sprintf('user: %s', $userName)); } else { return new Response('anonymous user'); } }); $this->app->get('/form', function (FormRequest $formRequest) { $formRequest->handle(TextType::class); return new Response('form handled'); }); }
public function setUp() { global $app; try { /* delete the existing entities before each test */ /* if we delete the entities the ids go out of sync, which means the data * in the fixures is not what the tests expect - guess we should use mocks * but I find that messy */ /* so we kill the whole db before each test and then reload the fixtures */ self::setUpBeforeClass(); /* load the fixtures */ $loader = new Loader(); $loader->loadFromDirectory('config/doctrine/fixtures/'); $fixtures = $loader->getFixtures(); $purger = new ORMPurger($app['orm.em']); $purger->setPurgeMode(ORMPurger::PURGE_MODE_DELETE); $executor = new ORMExecutor($app['orm.em'], $purger); $executor->execute($fixtures); } catch (\Exception $e) { /* ignored */ } parent::setUp(); }
public function setUp() { parent::setUp(); $this->app['db']->beginTransaction(); $this->app['db']->setRollbackOnly(); }
public function setUp() { parent::setUp(); $this->client = $this->createClient(); $this->client->followRedirects(true); }
public function setUp() { parent::setUp(); self::$DI = new \Pimple(); ini_set('memory_limit', '4096M'); error_reporting(-1); \PHPUnit_Framework_Error_Warning::$enabled = true; \PHPUnit_Framework_Error_Notice::$enabled = true; self::$DI['app'] = self::$DI->share(function ($DI) { return $this->loadApp($this->getApplicationPath()); }); self::$DI['cli'] = self::$DI->share(function ($DI) { return $this->loadCLI(); }); self::$DI['local-guzzle'] = self::$DI->share(function ($DI) { return new Guzzle(self::$DI['app']['conf']->get('servername')); }); self::$DI['client'] = self::$DI->share(function ($DI) { return new Client($DI['app'], []); }); self::$DI['feed_public'] = self::$DI->share(function ($DI) { return $DI['app']['repo.feeds']->find(self::$fixtureIds['feed']['public']['feed']); }); self::$DI['feed_public_entry'] = self::$DI->share(function ($DI) { return $DI['app']['repo.feed-entries']->find(self::$fixtureIds['feed']['public']['entry']); }); self::$DI['feed_public_token'] = self::$DI->share(function ($DI) { return $DI['app']['repo.feed-tokens']->find(self::$fixtureIds['feed']['public']['token']); }); self::$DI['feed_private'] = self::$DI->share(function ($DI) { return $DI['app']['repo.feeds']->find(self::$fixtureIds['feed']['private']['feed']); }); self::$DI['feed_private_entry'] = self::$DI->share(function ($DI) { return $DI['app']['repo.feed-entries']->find(self::$fixtureIds['feed']['private']['entry']); }); self::$DI['feed_private_token'] = self::$DI->share(function ($DI) { return $DI['app']['repo.feed-tokens']->find(self::$fixtureIds['feed']['private']['token']); }); self::$DI['basket_1'] = self::$DI->share(function ($DI) { return $DI['app']['repo.baskets']->find(self::$fixtureIds['basket']['basket_1']); }); self::$DI['basket_2'] = self::$DI->share(function ($DI) { return $DI['app']['repo.baskets']->find(self::$fixtureIds['basket']['basket_2']); }); self::$DI['basket_3'] = self::$DI->share(function ($DI) { return $DI['app']['repo.baskets']->find(self::$fixtureIds['basket']['basket_3']); }); self::$DI['basket_4'] = self::$DI->share(function ($DI) { return $DI['app']['repo.baskets']->find(self::$fixtureIds['basket']['basket_4']); }); self::$DI['token_1'] = self::$DI->share(function ($DI) { return $DI['app']['repo.tokens']->find(self::$fixtureIds['token']['token_1']); }); self::$DI['token_2'] = self::$DI->share(function ($DI) { return $DI['app']['repo.tokens']->find(self::$fixtureIds['token']['token_2']); }); self::$DI['token_invalid'] = self::$DI->share(function ($DI) { return $DI['app']['repo.tokens']->find(self::$fixtureIds['token']['token_invalid']); }); self::$DI['token_validation'] = self::$DI->share(function ($DI) { return $DI['app']['repo.tokens']->find(self::$fixtureIds['token']['token_validation']); }); $users = ['user' => 'test_phpunit', 'user_1' => 'user_1', 'user_2' => 'user_2', 'user_3' => 'user_3', 'user_guest' => 'user_guest', 'user_notAdmin' => 'test_phpunit_not_admin', 'user_alt1' => 'test_phpunit_alt1', 'user_alt2' => 'test_phpunit_alt2', 'user_template' => 'user_template']; $userFactory = function ($fixtureName) { if ('user_guest' === $fixtureName) { return function ($DI) use($fixtureName) { return $DI['app']['repo.users']->find(self::$fixtureIds['user'][$fixtureName]); }; } return function ($DI) use($fixtureName) { $user = $DI['app']['repo.users']->find(self::$fixtureIds['user'][$fixtureName]); self::resetUsersRights($DI['app'], $user); return $user; }; }; foreach ($users as $name => $fixtureName) { self::$DI[$name] = self::$DI->share($userFactory($fixtureName)); } self::$DI['registration_1'] = self::$DI->share(function ($DI) { return $DI['app']['repo.registrations']->find(self::$fixtureIds['registrations']['registration_1']); }); self::$DI['registration_2'] = self::$DI->share(function ($DI) { return $DI['app']['repo.registrations']->find(self::$fixtureIds['registrations']['registration_2']); }); self::$DI['registration_3'] = self::$DI->share(function ($DI) { return $DI['app']['repo.registrations']->find(self::$fixtureIds['registrations']['registration_3']); }); self::$DI['oauth2-app-user'] = self::$DI->share(function ($DI) { return $DI['app']['repo.api-applications']->find(self::$fixtureIds['oauth']['user']); }); self::$DI['webhook-event'] = self::$DI->share(function ($DI) { return $DI['app']['repo.webhook-event']->find(self::$fixtureIds['webhook']['event']); }); self::$DI['oauth2-app-user-not-admin'] = self::$DI->share(function ($DI) { return $DI['app']['repo.api-applications']->find(self::$fixtureIds['oauth']['user-not-admin']); }); self::$DI['oauth2-app-acc-user'] = self::$DI->share(function ($DI) { return $DI['app']['repo.api-accounts']->find(self::$fixtureIds['oauth']['acc-user']); }); self::$DI['oauth2-app-acc-user-not-admin'] = self::$DI->share(function ($DI) { return $DI['app']['repo.api-accounts']->find(self::$fixtureIds['oauth']['acc-user-not-admin']); }); self::$DI['logger'] = self::$DI->share(function () { $logger = new Logger('tests'); $logger->pushHandler(new NullHandler()); return $logger; }); self::$DI['collection'] = self::$DI->share(function ($DI) { return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll']); }); self::$DI['collection_no_access'] = self::$DI->share(function ($DI) { return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll_no_access']); }); self::$DI['collection_no_access_by_status'] = self::$DI->share(function ($DI) { return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll_no_status']); }); self::$DI['lazaret_1'] = self::$DI->share(function ($DI) { return $DI['app']['orm.em']->find('Phraseanet:LazaretFile', self::$fixtureIds['lazaret']['lazaret_1']); }); foreach (range(1, 7) as $i) { self::$DI['record_' . $i] = self::$DI->share(function ($DI) use($i) { return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], self::$fixtureIds['record']['record_' . $i]); }); } foreach (range(1, 3) as $i) { self::$DI['record_story_' . $i] = self::$DI->share(function ($DI) use($i) { return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], self::$fixtureIds['record']['record_story_' . $i]); }); } self::$DI['record_no_access_resolver'] = self::$DI->protect(function () { $id = 'no_access'; if (isset(self::$fixtureIds['records'][$id])) { return self::$fixtureIds['records'][$id]; } self::$recordsInitialized[] = $id; $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$DI['collection_no_access']); $record = record_adapter::createFromFile($file, self::$DI['app']); self::$DI['app']['subdef.generator']->generateSubdefs($record); self::$fixtureIds['records'][$id] = $record->get_record_id(); return self::$fixtureIds['records'][$id]; }); self::$DI['record_no_access_by_status_resolver'] = self::$DI->protect(function () { $id = 'no_access_by_status'; if (isset(self::$fixtureIds['records'][$id])) { return self::$fixtureIds['records'][$id]; } self::$recordsInitialized[] = $id; $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$DI['collection_no_access_by_status']); $record = record_adapter::createFromFile($file, self::$DI['app']); self::$DI['app']['subdef.generator']->generateSubdefs($record); self::$fixtureIds['records'][$id] = $record->get_record_id(); return self::$fixtureIds['records'][$id]; }); self::$DI['record_no_access'] = self::$DI->share(function ($DI) { return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], $DI['record_no_access_resolver']()); }); self::$DI['record_no_access_by_status'] = self::$DI->share(function ($DI) { return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], $DI['record_no_access_by_status_resolver']()); }); static $decodedFixtureIds; if (is_null($decodedFixtureIds)) { $decodedFixtureIds = json_decode(file_get_contents(sys_get_temp_dir() . '/fixtures.json'), true); } self::$fixtureIds = $decodedFixtureIds; }
public function setUp() { parent::setUp(); $this->client = $this->createClient(); $this->urlGenerator = $this->app['url_generator']; }
public function setUp() { parent::setUp(); if (null !== self::$DI) { unset(self::$DI['app']['dbal.provider']); } self::$DI = new \Pimple(); ini_set('memory_limit', '4096M'); \PHPUnit_Framework_Error_Warning::$enabled = true; \PHPUnit_Framework_Error_Notice::$enabled = true; self::$DI['app'] = self::$DI->share(function ($DI) { return $this->loadApp('/lib/Alchemy/Phrasea/Application/Root.php'); }); self::$DI['cli'] = self::$DI->share(function ($DI) { return $this->loadCLI(); }); self::$DI['local-guzzle'] = self::$DI->share(function ($DI) { return new Guzzle(self::$DI['app']['conf']->get('servername')); }); self::$DI['client'] = self::$DI->share(function ($DI) { return new Client($DI['app'], []); }); self::$DI['user'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['test_phpunit']); }); self::$DI['user_1'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['user_1']); }); self::$DI['user_2'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['user_2']); }); self::$DI['user_3'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['user_3']); }); self::$DI['user_guest'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['user_guest']); }); self::$DI['user_notAdmin'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['test_phpunit_not_admin']); }); self::$DI['user_alt1'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['test_phpunit_alt1']); }); self::$DI['user_alt2'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['test_phpunit_alt2']); }); self::$DI['user_template'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['user_template']); }); self::$DI['registration_1'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.registration']->getRepository()->find(self::$fixtureIds['registrations']['registration_1']); }); self::$DI['registration_2'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.registration']->getRepository()->find(self::$fixtureIds['registrations']['registration_2']); }); self::$DI['registration_3'] = self::$DI->share(function ($DI) { return $DI['app']['manipulator.registration']->getRepository()->find(self::$fixtureIds['registrations']['registration_3']); }); self::$DI['oauth2-app-user'] = self::$DI->share(function ($DI) { return new \API_OAuth2_Application($DI['app'], self::$fixtureIds['oauth']['user']); }); self::$DI['oauth2-app-user_notAdmin'] = self::$DI->share(function ($DI) { return new \API_OAuth2_Application($DI['app'], self::$fixtureIds['oauth']['user_notAdmin']); }); self::$DI['logger'] = self::$DI->share(function () { $logger = new Logger('tests'); $logger->pushHandler(new NullHandler()); return $logger; }); self::$DI['collection'] = self::$DI->share(function ($DI) { return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll']); }); self::$DI['collection_no_access'] = self::$DI->share(function ($DI) { return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll_no_access']); }); self::$DI['collection_no_access_by_status'] = self::$DI->share(function ($DI) { return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll_no_status']); }); if (!self::$booted) { if (!self::$DI['app']['phraseanet.configuration-tester']->isInstalled()) { echo "[0;31mPhraseanet is not set up[0;37m\n"; exit(1); } self::$fixtureIds = array_merge(self::$fixtureIds, json_decode(file_get_contents(__DIR__ . '/../fixtures.json'), true)); self::resetUsersRights(self::$DI['app'], self::$DI['user']); self::resetUsersRights(self::$DI['app'], self::$DI['user_notAdmin']); self::$booted = true; } self::$DI['lazaret_1'] = self::$DI->share(function ($DI) { return $DI['app']['EM']->find('Phraseanet:LazaretFile', self::$fixtureIds['lazaret']['lazaret_1']); }); foreach (range(1, 7) as $i) { self::$DI['record_' . $i] = self::$DI->share(function ($DI) use($i) { return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], self::$fixtureIds['record']['record_' . $i]); }); } foreach (range(1, 3) as $i) { self::$DI['record_story_' . $i] = self::$DI->share(function ($DI) use($i) { return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], self::$fixtureIds['record']['record_story_' . $i]); }); } self::$DI['record_no_access_resolver'] = self::$DI->protect(function () { $id = 'no_access'; if (isset(self::$fixtureIds['records'][$id])) { return self::$fixtureIds['records'][$id]; } self::$recordsInitialized[] = $id; $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$DI['collection_no_access']); $record = record_adapter::createFromFile($file, self::$DI['app']); self::$DI['app']['subdef.generator']->generateSubdefs($record); self::$fixtureIds['records'][$id] = $record->get_record_id(); return self::$fixtureIds['records'][$id]; }); self::$DI['record_no_access_by_status_resolver'] = self::$DI->protect(function () { $id = 'no_access_by_status'; if (isset(self::$fixtureIds['records'][$id])) { return self::$fixtureIds['records'][$id]; } self::$recordsInitialized[] = $id; $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$DI['collection_no_access_by_status']); $record = record_adapter::createFromFile($file, self::$DI['app']); self::$DI['app']['subdef.generator']->generateSubdefs($record); self::$fixtureIds['records'][$id] = $record->get_record_id(); return self::$fixtureIds['records'][$id]; }); self::$DI['record_no_access'] = self::$DI->share(function ($DI) { return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], $DI['record_no_access_resolver']()); }); self::$DI['record_no_access_by_status'] = self::$DI->share(function ($DI) { return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], $DI['record_no_access_by_status_resolver']()); }); if (!self::$testCaseBooted) { $this->bootTestCase(); } self::$testCaseBooted = true; }
public function setUp() { parent::setUp(); }
public function setUp() { $this->profilerDirectory = sys_get_temp_dir() . '/' . substr(sha1(microtime()), 0, 8); mkdir($this->profilerDirectory); parent::setUp(); }
public function setUp() { parent::setUp(); $this->loadFixtures(); }
/** * PHPUnit setUp. */ public function setUp() { parent::setUp(); $this->client = $this->createClient(); }
public function setUp() { $this->testEnvironment = TestEnvironment::newInstance(); $this->apiFactory = $this->testEnvironment->getFactory(); parent::setUp(); }