Ejemplo n.º 1
0
 protected function setUp()
 {
     parent::setUp();
     $_SERVER['SCRIPT_FILENAME'] = "/index.php";
     $_SERVER['SCRIPT_NAME'] = "/index.php";
     $this->mockWebApplication();
 }
Ejemplo n.º 2
0
 protected function setUp()
 {
     parent::setUp();
     $this->security = new ExposedSecurity();
     $this->security->derivationIterations = 1000;
     // speed up test running
 }
Ejemplo n.º 3
0
 protected function setUp()
 {
     parent::setUp();
     $this->_cacheController = Yii::createObject(['class' => 'yiiunit\\framework\\console\\controllers\\CacheConsoledController', 'interactive' => false], [null, null]);
     //id and module are null
     $this->mockApplication(['components' => ['firstCache' => 'yii\\caching\\ArrayCache', 'secondCache' => 'yii\\caching\\ArrayCache']]);
 }
Ejemplo n.º 4
0
 protected function setUp()
 {
     parent::setUp();
     $this->mockApplication();
     Yii::$app->set('db', ['class' => Connection::className(), 'dsn' => 'sqlite::memory:']);
     Yii::$app->db->createCommand()->createTable('session', ['id' => 'string', 'expire' => 'integer', 'data' => 'text', 'user_id' => 'integer'])->execute();
 }
Ejemplo n.º 5
0
 protected function setUp()
 {
     parent::setUp();
     IntlTestHelper::setIntlStatus($this);
     $this->mockApplication(['timeZone' => 'UTC', 'language' => 'ru-RU']);
     $this->formatter = new Formatter(['locale' => 'en-US']);
 }
Ejemplo n.º 6
0
 protected function setUp()
 {
     parent::setUp();
     $this->mockApplication();
     Yii::setAlias('@testWeb', '/');
     Yii::setAlias('@testWebRoot', '@yiiunit/data/web');
 }
Ejemplo n.º 7
0
 public function setUp()
 {
     $dsn = getenv('DB_DRIVER') . ':host=' . getenv('DB_HOST') . ';dbname=' . getenv('DB_NAME');
     $this->databaseConfig = ['class' => Connection::class, 'dsn' => $dsn, 'username' => getenv('DB_USERNAME'), 'password' => getenv('DB_PASSWORD'), 'charset' => 'utf8'];
     $this->mockWebApplication(['bootstrap' => ['algolia'], 'components' => ['algolia' => ['class' => AlgoliaComponent::class, 'applicationId' => getenv('ALGOLIA_ID'), 'apiKey' => getenv('ALGOLIA_KEY')], 'db' => $this->databaseConfig]]);
     $this->migrateTestSchema();
     parent::setUp();
 }
Ejemplo n.º 8
0
 public function setUp()
 {
     $this->migrateControllerClass = MigrateController::className();
     $this->migrationBaseClass = Migration::className();
     $this->mockApplication(['components' => ['db' => ['class' => 'yii\\db\\Connection', 'dsn' => 'sqlite::memory:']]]);
     $this->setUpMigrationPath();
     parent::setUp();
 }
Ejemplo n.º 9
0
 protected function setUp()
 {
     parent::setUp();
     $_SERVER['SCRIPT_FILENAME'] = "/index.php";
     $_SERVER['SCRIPT_NAME'] = "/index.php";
     $appConfig = ['components' => ['user' => ['identityClass' => UserIdentity::className()]], 'controllerMap' => ['test' => TestController::className()]];
     $this->mockWebApplication($appConfig);
 }
 public function setUp()
 {
     parent::setUp();
     $mockAlgoliaFactory = m::mock(AlgoliaFactory::class);
     $this->mockAlgoliaClient = m::mock(Client::class);
     $mockAlgoliaFactory->shouldReceive('make')->andReturn($this->mockAlgoliaClient);
     Yii::$container->set(AlgoliaFactory::class, $mockAlgoliaFactory);
     $this->mockWebApplication(['bootstrap' => ['algolia'], 'components' => ['algolia' => ['class' => AlgoliaComponent::class, 'applicationId' => 'test', 'apiKey' => 'secret']]]);
 }
Ejemplo n.º 11
0
 protected function setUp()
 {
     parent::setUp();
     if (!extension_loaded('intl')) {
         $this->markTestSkipped('intl extension is required.');
     }
     $this->mockApplication(['timeZone' => 'UTC']);
     $this->formatter = new Formatter(['locale' => 'en-US']);
 }
Ejemplo n.º 12
0
 protected function setUp()
 {
     parent::setUp();
     $this->mockApplication();
     $this->tmpPath = \Yii::$app->runtimePath . '/assetConverterTest_' . getmypid();
     if (!is_dir($this->tmpPath)) {
         mkdir($this->tmpPath, 0777, true);
     }
 }
Ejemplo n.º 13
0
 protected function setUp()
 {
     parent::setUp();
     // dirty way to have Request object not throwing exception when running testHomeLinkNull()
     $_SERVER['SCRIPT_FILENAME'] = "/index.php";
     $_SERVER['SCRIPT_NAME'] = "/index.php";
     $this->mockWebApplication();
     $this->breadcrumbs = new Breadcrumbs();
 }
Ejemplo n.º 14
0
 /**
  * @inheritdoc
  */
 protected function setUp()
 {
     parent::setUp();
     file_put_contents($this->itemFile, file_get_contents(__DIR__ . '/data/_rbac/items.php'));
     file_put_contents($this->assignmentFile, file_get_contents(__DIR__ . '/data/_rbac/assignments.php'));
     file_put_contents($this->ruleFile, file_get_contents(__DIR__ . '/data/_rbac/rules.php'));
     $this->mockWebApplication(['components' => ['authManager' => ['class' => \yii\rbac\PhpManager::className(), 'itemFile' => $this->itemFile, 'assignmentFile' => $this->assignmentFile, 'ruleFile' => $this->ruleFile]]]);
     $this->itemController = new ItemController('item', Yii::$app);
     $this->itemController->detachBehavior('verbs');
 }
Ejemplo n.º 15
0
 protected function setUp()
 {
     parent::setUp();
     if (defined('HHVM_VERSION')) {
         // https://github.com/facebook/hhvm/issues/1447
         $this->markTestSkipped('Can not test on HHVM because require is cached.');
     }
     $this->mockApplication();
     $this->_fixtureController = Yii::createObject(['class' => 'yiiunit\\extensions\\faker\\FixtureConsoledController', 'interactive' => false, 'fixtureDataPath' => '@runtime/faker', 'templatePath' => '@yiiunit/data/extensions/faker/templates'], ['fixture-faker', Yii::$app]);
 }
 public function setUp()
 {
     parent::setUp();
     $this->mockWebApplication(['bootstrap' => ['algolia'], 'components' => ['algolia' => ['class' => AlgoliaComponent::class, 'applicationId' => 'test', 'apiKey' => 'secret']]]);
     $this->dummyAlgoliaManager = m::mock(AlgoliaManager::class);
     // Override the Registered AlgoliaManager with a mock
     Yii::$container->set(AlgoliaManager::class, function () {
         return $this->dummyAlgoliaManager;
     });
 }
Ejemplo n.º 17
0
 protected function setUp()
 {
     parent::setUp();
     $databases = self::getParam('databases');
     $this->database = $databases[$this->driverName];
     $pdo_database = 'pdo_' . $this->driverName;
     if (!extension_loaded('pdo') || !extension_loaded($pdo_database)) {
         $this->markTestSkipped('pdo and ' . $pdo_database . ' extension are required.');
     }
     $this->mockApplication();
 }
Ejemplo n.º 18
0
 protected function setUp()
 {
     parent::setUp();
     if (!extension_loaded('mongo')) {
         $this->markTestSkipped('mongo extension required.');
     }
     $config = self::getParam('mongodb');
     if (!empty($config)) {
         $this->mongoDbConfig = $config;
     }
     $this->mockApplication();
     static::loadClassMap();
 }
Ejemplo n.º 19
0
 protected function setUp()
 {
     parent::setUp();
     if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) {
         $this->markTestSkipped('pdo and pdo_mysql extension are required.');
     }
     $config = $this->getParam('sphinx');
     if (!empty($config)) {
         $this->sphinxConfig = $config['sphinx'];
         $this->dbConfig = $config['db'];
     }
     $this->mockApplication();
     static::loadClassMap();
 }
Ejemplo n.º 20
0
 protected function setUp()
 {
     $databases = $this->getParam('databases');
     $params = isset($databases['redis']) ? $databases['redis'] : null;
     if ($params === null) {
         $this->markTestSkipped('No redis server connection configured.');
     }
     $connection = new Connection($params);
     if (!@stream_socket_client($connection->hostname . ':' . $connection->port, $errorNumber, $errorDescription, 0.5)) {
         $this->markTestSkipped('No redis server running at ' . $connection->hostname . ':' . $connection->port . ' : ' . $errorNumber . ' - ' . $errorDescription);
     }
     $this->mockApplication(['components' => ['redis' => $connection]]);
     parent::setUp();
 }
Ejemplo n.º 21
0
 protected function setUp()
 {
     parent::setUp();
     // emulate disabled intl extension
     // enable it only for tests prefixed with testIntl
     static::$enableIntl = null;
     if (strncmp($this->getName(false), 'testIntl', 8) === 0) {
         if (!extension_loaded('intl')) {
             $this->markTestSkipped('intl extension is not installed.');
         }
         static::$enableIntl = true;
     } else {
         static::$enableIntl = false;
     }
     $this->mockApplication(['timeZone' => 'UTC', 'language' => 'ru-RU']);
     $this->formatter = new Formatter(['locale' => 'en-US']);
 }
 protected function setUp()
 {
     $this->mockApplication();
     $databases = self::getParam('databases');
     $params = isset($databases['elasticsearch']) ? $databases['elasticsearch'] : null;
     if ($params === null || !isset($params['dsn'])) {
         $this->markTestSkipped('No elasticsearch server connection configured.');
     }
     $dsn = explode('/', $params['dsn']);
     $host = $dsn[2];
     if (strpos($host, ':') === false) {
         $host .= ':9200';
     }
     if (!@stream_socket_client($host, $errorNumber, $errorDescription, 0.5)) {
         $this->markTestSkipped('No elasticsearch server running at ' . $params['dsn'] . ' : ' . $errorNumber . ' - ' . $errorDescription);
     }
     parent::setUp();
 }
Ejemplo n.º 23
0
 protected function setUp()
 {
     parent::setUp();
     // dirty way to have Request object not throwing exception when running testHomeLinkNull()
     $_SERVER['SCRIPT_FILENAME'] = "index.php";
     $_SERVER['SCRIPT_NAME'] = "index.php";
     $this->mockWebApplication();
     Yii::setAlias('@testWeb', '/');
     Yii::setAlias('@testWebRoot', '@yiiunit/data/web');
     $this->helperModel = new DynamicModel(['attributeName']);
     ob_start();
     $this->helperForm = new ActiveForm(['action' => '/something']);
     ob_end_clean();
     $this->activeField = new ActiveFieldExtend(true);
     $this->activeField->form = $this->helperForm;
     $this->activeField->form->setView($this->getView());
     $this->activeField->model = $this->helperModel;
     $this->activeField->attribute = $this->attributeName;
 }
Ejemplo n.º 24
0
 protected function setUp()
 {
     parent::setUp();
     if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) {
         $this->markTestSkipped('pdo and pdo_mysql extension are required.');
     }
     $config = self::getParam('sphinx');
     if (!empty($config)) {
         $this->sphinxConfig = $config['sphinx'];
         $this->dbConfig = $config['db'];
     }
     // check whether sphinx is running and skip tests if not.
     if (preg_match('/host=([\\w\\d.]+)/i', $this->sphinxConfig['dsn'], $hm) && preg_match('/port=(\\d+)/i', $this->sphinxConfig['dsn'], $pm)) {
         if (!@stream_socket_client($hm[1] . ':' . $pm[1], $errorNumber, $errorDescription, 0.5)) {
             $this->markTestSkipped('No Sphinx searchd running at ' . $hm[1] . ':' . $pm[1] . ' : ' . $errorNumber . ' - ' . $errorDescription);
         }
     }
     $this->mockApplication();
     static::loadClassMap();
 }
Ejemplo n.º 25
0
 protected function setUp()
 {
     parent::setUp();
     $this->_cacheController = Yii::createObject(['class' => 'yiiunit\\framework\\console\\controllers\\SilencedCacheController', 'interactive' => false], [null, null]);
     //id and module are null
     $databases = self::getParam('databases');
     $config = $databases[$this->driverName];
     $pdoDriver = 'pdo_' . $this->driverName;
     if (!extension_loaded('pdo') || !extension_loaded($pdoDriver)) {
         $this->markTestSkipped('pdo and ' . $pdoDriver . ' extensions are required.');
     }
     $this->mockApplication(['components' => ['firstCache' => 'yii\\caching\\ArrayCache', 'secondCache' => 'yii\\caching\\ArrayCache', 'session' => 'yii\\web\\CacheSession', 'db' => ['class' => isset($config['class']) ? $config['class'] : 'yii\\db\\Connection', 'dsn' => $config['dsn'], 'username' => isset($config['username']) ? $config['username'] : null, 'password' => isset($config['password']) ? $config['password'] : null, 'enableSchemaCache' => true, 'schemaCache' => 'firstCache']]]);
     if (isset($config['fixture'])) {
         Yii::$app->db->open();
         $lines = explode(';', file_get_contents($config['fixture']));
         foreach ($lines as $line) {
             if (trim($line) !== '') {
                 Yii::$app->db->pdo->exec($line);
             }
         }
     }
 }
Ejemplo n.º 26
0
 protected function setUp()
 {
     parent::setUp();
     $this->mockApplication();
 }
Ejemplo n.º 27
0
 protected function setUp()
 {
     parent::setUp();
     $this->mockApplication(['components' => ['request' => ['class' => 'yii\\web\\Request', 'url' => '/test', 'enableCsrfValidation' => false], 'response' => ['class' => 'yii\\web\\Response']]]);
 }
Ejemplo n.º 28
0
 protected function setUp()
 {
     parent::setUp();
     IntlTestHelper::setIntlStatus($this);
     $this->mockApplication(['timeZone' => 'UTC', 'language' => 'ru-RU']);
 }
Ejemplo n.º 29
0
 protected function setUp()
 {
     parent::setUp();
     $this->mockApplication();
     $this->i18n = new I18N(['translations' => ['test' => new PhpMessageSource(['basePath' => '@yiiunit/data/i18n/messages'])]]);
 }
Ejemplo n.º 30
0
 protected function setUp()
 {
     parent::setUp();
     $this->_fixtureController = Yii::createObject(['class' => 'yiiunit\\framework\\console\\controllers\\FixtureConsoledController', 'interactive' => false, 'globalFixtures' => [], 'namespace' => 'yiiunit\\data\\console\\controllers\\fixtures'], [null, null]);
     //id and module are null
 }