Beispiel #1
0
 /**
  * Loads fixture data.
  *
  * @return void
  * @since 0.1.0
  */
 public function loadRuntimeFixtures()
 {
     $serverName = false;
     if (isset($_SERVER['SERVER_NAME'])) {
         $serverName = $_SERVER['SERVER_NAME'];
     }
     $maps = array('users' => array('username' => 'login', 'rawPassword' => 'password'), 'posts' => array('name' => 'title', 'user_id' => 'author', 'category_id' => 'category'), 'categories' => array('name' => 'title'));
     $dbFixtures = \Yii::app()->fixtureManager->getFixtures();
     foreach ($maps as $fixture => $map) {
         $data = (require $dbFixtures[$fixture]);
         $index = 0;
         $keyBase = "data:{$fixture}";
         foreach ($data as $item) {
             Fixtures::add($keyBase, $item);
             foreach ($item as $field => $value) {
                 if (isset($map[$field])) {
                     $key = $keyBase . "[{$index}]:" . $map[$field];
                 } else {
                     $key = $keyBase . "[{$index}]:" . $field;
                 }
                 Fixtures::add($key, $value);
             }
             $index++;
         }
         Fixtures::add($keyBase . ':length', $index);
     }
     Fixtures::add('data:random:int', mt_rand(0, PHP_INT_MAX));
     Fixtures::add('data:random:string', md5(Fixtures::get('data:random:int')));
     Fixtures::add('defaults:app:language', \Yii::app()->language);
     Fixtures::add('defaults:app:name', \Yii::app()->name);
     Fixtures::add('defaults:app:theme', \Yii::app()->theme->name);
     Fixtures::add('defaults:server:host', $serverName);
 }
Beispiel #2
0
if (!is_file($autoload)) {
    throw new \RuntimeException("Please run: <i>bin/grav install</i>");
}
use Grav\Common\Grav;
// Register the auto-loader.
$loader = (require_once $autoload);
if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
    throw new \RuntimeException(sprintf('You are running PHP %s, but Grav needs at least <strong>PHP %s</strong> to run.', $ver, $req));
}
// Set timezone to default, falls back to system if php.ini not set
date_default_timezone_set(@date_default_timezone_get());
// Set internal encoding if mbstring loaded
if (!extension_loaded('mbstring')) {
    throw new \RuntimeException("'mbstring' extension is not loaded.  This is required for Grav to run correctly");
}
mb_internal_encoding('UTF-8');
// Get the Grav instance
$grav = Grav::instance(['loader' => $loader]);
$grav['uri']->init();
$grav['debugger']->init();
$grav['assets']->init();
$grav['config']->set('system.cache.enabled', false);
/** @var UniformResourceLocator $locator */
$locator = $grav['locator'];
$locator->addPath('tests', '', 'tests', false);
// Set default $_SERVER value used for nonces
empty($_SERVER['HTTP_CLIENT_IP']) && ($_SERVER['HTTP_CLIENT_IP'] = '127.0.0.1');
$fake = Factory::create();
Fixtures::add('grav', $grav);
Fixtures::add('fake', $fake);
Beispiel #3
0
<?php

use Codeception\Util\Fixtures;
/**
 * Bootstrap for Codeception tests
 *
 * @author Gawain Lynch <*****@*****.**>
 */
// User IDs
Fixtures::add('users', ['admin' => ['username' => 'admin', 'password' => 'topsecret', 'email' => '*****@*****.**', 'displayname' => 'Admin Person'], 'editor' => ['username' => 'editor', 'password' => 'nomoresecrets', 'email' => '*****@*****.**', 'displayname' => 'Editor Person'], 'manager' => ['username' => 'manager', 'password' => 'cantkeepsecrets', 'email' => '*****@*****.**', 'displayname' => 'Manager Person'], 'developer' => ['username' => 'developer', 'password' => '~n0Tne1k&nGu3$$', 'email' => '*****@*****.**', 'displayname' => 'Developer Person'], 'lemmings' => ['username' => 'lemmings', 'password' => 'MikeDaillyDavidJones', 'email' => '*****@*****.**', 'displayname' => 'Lemmings Person']]);
// Files that we'll backup. If they exist when we run, then we keep the
// original in tact before starting the suite run
Fixtures::add('backups', [INSTALL_ROOT . '/app/config/config.yml' => false, INSTALL_ROOT . '/app/config/contenttypes.yml' => false, INSTALL_ROOT . '/app/config/menu.yml' => false, INSTALL_ROOT . '/app/config/permissions.yml' => false, INSTALL_ROOT . '/app/config/routing.yml' => false, INSTALL_ROOT . '/app/config/taxonomy.yml' => false, BOLT_ROOT . '/app/resources/translations/en_GB/messages.en_GB.yml' => true, BOLT_ROOT . '/app/resources/translations/en_GB/infos.en_GB.yml' => true, BOLT_ROOT . '/app/resources/translations/en_GB/contenttypes.en_GB.yml' => true, INSTALL_ROOT . '/app/database/bolt.db' => false, INSTALL_ROOT . '/theme/base-2014/_footer.twig' => true]);
// Session and authentication tokens
Fixtures::add('tokenNames', ['session' => 'bolt_session_' . md5('localhost:8123/'), 'authtoken' => 'bolt_authtoken_' . md5('localhost:8123/')]);
Beispiel #4
0
<?php

use Codeception\Util\Fixtures;
/**
 * Bootstrap for Codeception tests
 *
 * @author Gawain Lynch <*****@*****.**>
 */
// User IDs
Fixtures::add('users', ['admin' => ['username' => 'admin', 'password' => 'topsecret', 'email' => '*****@*****.**', 'displayname' => 'Admin Person'], 'editor' => ['username' => 'editor', 'password' => 'nomoresecrets', 'email' => '*****@*****.**', 'displayname' => 'Editor Person'], 'manager' => ['username' => 'manager', 'password' => 'cantkeepsecrets', 'email' => '*****@*****.**', 'displayname' => 'Manager Person'], 'developer' => ['username' => 'developer', 'password' => '~n0Tne1k&nGu3$$', 'email' => '*****@*****.**', 'displayname' => 'Developer Person']]);
// Files that we'll backup. If they exist when we run, then we keep the
// original in tact before starting the suite run
Fixtures::add('backups', [INSTALL_ROOT . '/app/config/config.yml' => false, INSTALL_ROOT . '/app/config/contenttypes.yml' => false, INSTALL_ROOT . '/app/config/menu.yml' => false, INSTALL_ROOT . '/app/config/permissions.yml' => false, INSTALL_ROOT . '/app/config/routing.yml' => false, INSTALL_ROOT . '/app/config/taxonomy.yml' => false, BOLT_ROOT . '/app/resources/translations/en_GB/messages.en_GB.yml' => true, BOLT_ROOT . '/app/resources/translations/en_GB/infos.en_GB.yml' => true, BOLT_ROOT . '/app/resources/translations/en_GB/contenttypes.en_GB.yml' => true, INSTALL_ROOT . '/app/database/bolt.db' => false, INSTALL_ROOT . '/theme/base-2014/_footer.twig' => true]);
Beispiel #5
0
<?php

use GuzzleHttp\Psr7\Response as GuzzleResponse;
use Codeception\Util\Fixtures;
/**
 * Load in Fixture files
 */
$fixtureDir = __DIR__ . '/fixtures/';
// http://www.sainsburys.co.uk/shop/gb/groceries/fruit-veg/ripe---ready
Fixtures::add('ripeAndReady', new GuzzleResponse(200, ['Content-Type' => 'text/html; charset=UTF-8'], file_get_contents($fixtureDir . 'ripe---ready.html')));
// http://www.sainsburys.co.uk/shop/gb/groceries/ripe---ready/sainsburys-avocado-xl-pinkerton-loose-300g
Fixtures::add('avocado', new GuzzleResponse(200, ['Content-Type' => 'text/html; charset=UTF-8'], file_get_contents($fixtureDir . 'sainsburys-avocado-xl-pinkerton-loose-300g.html')));
// http://www.sainsburys.co.uk/shop/gb/groceries/drinks/ale-stout
Fixtures::add('aleAndStout', new GuzzleResponse(200, ['Content-Type' => 'text/html; charset=UTF-8'], file_get_contents($fixtureDir . 'ale-stout.html')));
for ($page = 2; $page <= 7; $page++) {
    Fixtures::add('aleAndStoutPage' . $page, new GuzzleResponse(200, ['Content-Type' => 'text/html; charset=UTF-8'], file_get_contents($fixtureDir . 'ale-stout_page' . $page . '.html')));
}
// http://www.sainsburys.co.uk/shop/gb/groceries/ale-stout/adnams-broadside-ale-500ml
Fixtures::add('broadside', new GuzzleResponse(200, ['Content-Type' => 'text/html; charset=UTF-8'], file_get_contents($fixtureDir . 'adnams-broadside-ale-500ml.html')));
<?php

// Here you can initialize variables that will be available to your tests
use Phalcon\Mvc\Application;
use Phalcon\DI\FactoryDefault;
use Codeception\Util\Fixtures;
use Codeception\Util\Autoload;
defined('APP_PATH') || define('APP_PATH', dirname(dirname(dirname(__FILE__))));
defined('CONFIG_PATH') || define('CONFIG_PATH', dirname(dirname(__FILE__)));
require APP_PATH . "/vendor/autoload.php";
$config = (include CONFIG_PATH . "/config/config.php");
$di = new FactoryDefault();
require CONFIG_PATH . "/config/services.php";
$application = new Application();
$application->setDI($di);
Fixtures::add("app", $application);
Autoload::addNamespace('SimpleHelpers\\Libs\\Github', '/src/');
<?php

$rabman = ['base_uri' => 'http://rabbit-server:15672', 'default' => ['auth' => ['guest', 'guest']]];
\Codeception\Util\Fixtures::add('rabman-opt', $rabman);
Beispiel #8
0
<?php

// This is global bootstrap for autoloading
use Codeception\Util\Fixtures;
Fixtures::add('username', '*****@*****.**');
Fixtures::add('password', 'password');
<?php
// Here you can initialize variables that will be available to your tests
use Codeception\Util\Fixtures;
Fixtures::add('importFolder', '/var/www/registry/tests/_data/');
Beispiel #10
0
<?php

use Codeception\Util\Fixtures;
$container = (require __DIR__ . '/../app/bootstrap.php');
Fixtures::add('container', $container);
 /**
  * @When /^I have an array "(\w+)" with values \[(.+)]$/i
  */
 public function iHaveArray($var, $values)
 {
     $array = preg_split('/,\\s?/', $values);
     Fixtures::add($var, $array);
 }
<?php

use Codeception\Util\Fixtures;
require dirname(__FILE__) . '/../../src/config/constants.php';
Fixtures::add('devs', ['igorsantos07', 'brenoc', 'firstdoit']);
Fixtures::add('orgs', ['laravel-ardent', 'vtex', 'laravel', 'Luracast', 'yiisoft', 'PHPRio', 'HotelUrbano']);
Fixtures::add('small_orgs', ['laravel-ardent', 'laravel', 'Luracast', 'PHPRio']);
$faker = Faker\Factory::create();
Fixtures::add('faker', $faker);
Fixtures::add('coupons', [['code' => 'SHIPIT', 'discount' => '0.20'], ['code' => 'NOTTHIS', 'discount' => '0.05']]);
/**
 * Turns bad floats into stringified floats, that will contain precisely 2 decimal places.
 * @param $number
 * @return string
 */
function floatify($number)
{
    return number_format(round($number, 2), 2, '.', '');
}
 /**
  * @Given I have a parameter :param with value :value
  */
 public function iHaveAParameterWithValue($param, $value)
 {
     Fixtures::add($param, $value);
 }
$createOrders = function ($Customer, $numberOfOrders = 5) use($app, $faker) {
    $Orders = array();
    for ($i = 0; $i < $numberOfOrders; $i++) {
        $Order = $app['eccube.fixture.generator']->createOrder($Customer);
        $Status = $app['eccube.repository.order_status']->find($faker->numberBetween(1, 7));
        $OrderDate = $faker->dateTimeThisYear();
        $Order->setOrderStatus($Status);
        $Order->setOrderDate($OrderDate);
        $app['orm.em']->flush($Order);
        $Orders[] = $Order;
    }
    return $Orders;
};
/** 受注を生成するクロージャ. */
Fixtures::add('createOrders', $createOrders);
$findPlugins = function () use($app) {
    return $app['orm.em']->getRepository('Eccube\\Entity\\Plugin')->findAll();
};
/** プラグインを検索するクロージャ */
Fixtures::add('findPlugins', $findPlugins);
$findPluginByCode = function ($code = null) use($app) {
    return $app['orm.em']->getRepository('Eccube\\Entity\\Plugin')->findOneBy(['code' => $code]);
};
/** プラグインを検索するクロージャ */
Fixtures::add('findPluginByCode', $findPluginByCode);
$findCustomers = function () use($app) {
    return $app['orm.em']->getRepository('Eccube\\Entity\\Customer')->createQueryBuilder('c')->where('c.del_flg = 0')->getQuery()->getResult();
};
/** 会員を検索するクロージャ */
Fixtures::add('findCustomers', $findCustomers);
<?php

// This is global bootstrap for autoloading
use Codeception\Util\Fixtures;
Fixtures::add('validModuleConfig', ['root' => 'testsites/drupal7/drupal-7.x']);
Fixtures::add('invalidModuleConfig', ['root' => 'this/is/a/fake/path']);