当前位置: 首页>>代码示例>>PHP>>正文


PHP Fixtures::add方法代码示例

本文整理汇总了PHP中Codeception\Util\Fixtures::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Fixtures::add方法的具体用法?PHP Fixtures::add怎么用?PHP Fixtures::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Codeception\Util\Fixtures的用法示例。


在下文中一共展示了Fixtures::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadRuntimeFixtures

 /**
  * 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);
 }
开发者ID:DavBfr,项目名称:BlogMVC,代码行数:39,代码来源:BootstrapHelper.php

示例2:

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);
开发者ID:nikkialgar,项目名称:grav,代码行数:30,代码来源:_bootstrap.php

示例3:

<?php

use Codeception\Util\Fixtures;
/**
 * Bootstrap for Codeception tests
 *
 * @author Gawain Lynch <gawain.lynch@gmail.com>
 */
// User IDs
Fixtures::add('users', ['admin' => ['username' => 'admin', 'password' => 'topsecret', 'email' => 'admin@example.com', 'displayname' => 'Admin Person'], 'editor' => ['username' => 'editor', 'password' => 'nomoresecrets', 'email' => 'editor@example.com', 'displayname' => 'Editor Person'], 'manager' => ['username' => 'manager', 'password' => 'cantkeepsecrets', 'email' => 'manager@example.com', 'displayname' => 'Manager Person'], 'developer' => ['username' => 'developer', 'password' => '~n0Tne1k&nGu3$$', 'email' => 'developer@example.com', 'displayname' => 'Developer Person'], 'lemmings' => ['username' => 'lemmings', 'password' => 'MikeDaillyDavidJones', 'email' => 'lemmings@example.com', '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/')]);
开发者ID:nectd,项目名称:nectd-web,代码行数:15,代码来源:_bootstrap.php

示例4:

<?php

use Codeception\Util\Fixtures;
/**
 * Bootstrap for Codeception tests
 *
 * @author Gawain Lynch <gawain.lynch@gmail.com>
 */
// User IDs
Fixtures::add('users', ['admin' => ['username' => 'admin', 'password' => 'topsecret', 'email' => 'admin@example.com', 'displayname' => 'Admin Person'], 'editor' => ['username' => 'editor', 'password' => 'nomoresecrets', 'email' => 'editor@example.com', 'displayname' => 'Editor Person'], 'manager' => ['username' => 'manager', 'password' => 'cantkeepsecrets', 'email' => 'manager@example.com', 'displayname' => 'Manager Person'], 'developer' => ['username' => 'developer', 'password' => '~n0Tne1k&nGu3$$', 'email' => 'developer@example.com', '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]);
开发者ID:aaleksu,项目名称:bolt_cm,代码行数:13,代码来源:_bootstrap.php

示例5: GuzzleResponse

<?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')));
开发者ID:peterhough,项目名称:sainsburys,代码行数:19,代码来源:_bootstrap.php

示例6: define

<?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/');
开发者ID:simple-helpers,项目名称:php-github-api-wrap,代码行数:17,代码来源:_bootstrap.php

示例7:

<?php

$rabman = ['base_uri' => 'http://rabbit-server:15672', 'default' => ['auth' => ['guest', 'guest']]];
\Codeception\Util\Fixtures::add('rabman-opt', $rabman);
开发者ID:imega,项目名称:rabbitmq-management-api,代码行数:4,代码来源:_bootstrap.php

示例8:

<?php

// This is global bootstrap for autoloading
use Codeception\Util\Fixtures;
Fixtures::add('username', 'user@example.com');
Fixtures::add('password', 'password');
开发者ID:njmube,项目名称:invoice-ninja,代码行数:6,代码来源:_bootstrap.php

示例9:

<?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/');
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:4,代码来源:_bootstrap.php

示例10:

<?php

use Codeception\Util\Fixtures;
$container = (require __DIR__ . '/../app/bootstrap.php');
Fixtures::add('container', $container);
开发者ID:janlavicka,项目名称:devstack,代码行数:5,代码来源:_bootstrap.php

示例11: iHaveArray

 /**
  * @When /^I have an array "(\w+)" with values \[(.+)]$/i
  */
 public function iHaveArray($var, $values)
 {
     $array = preg_split('/,\\s?/', $values);
     Fixtures::add($var, $array);
 }
开发者ID:edno,项目名称:codeception-gherkin-param,代码行数:8,代码来源:Acceptance.php

示例12: dirname

<?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, '.', '');
}
开发者ID:igorsantos07,项目名称:developer-shop,代码行数:19,代码来源:_bootstrap.php

示例13: iHaveAParameterWithValue

 /**
  * @Given I have a parameter :param with value :value
  */
 public function iHaveAParameterWithValue($param, $value)
 {
     Fixtures::add($param, $value);
 }
开发者ID:edno,项目名称:codeception-gherkin-param,代码行数:7,代码来源:AcceptanceTester.php

示例14: function

$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);
开发者ID:EC-CUBE,项目名称:eccube-codeception,代码行数:30,代码来源:_bootstrap.php

示例15:

<?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']);
开发者ID:chapabu,项目名称:codeception-module-drupal,代码行数:6,代码来源:_bootstrap.php


注:本文中的Codeception\Util\Fixtures::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。