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


PHP FunctionalTester::makeModel方法代码示例

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


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

示例1: FunctionalTester

<?php

$I = new FunctionalTester($scenario);
$I->wantTo('Add a product to cart that has options');
// Make models
// Create a product with some options
$product = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'inStock', 1);
$options[] = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'radio', 1);
$options[] = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'select', 1);
$options[] = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'text', 1);
$product->options()->saveMany($options);
// Create another product so we can try and force it's option on to the 'correct' product
$unrelatedProduct = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'inStock', 1);
$unrelatedOption = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'select', 1);
$unrelatedProduct->options()->save($unrelatedOption);
$I->amOnRoute('shop.product.show', $product->slug);
// Randomly choose the option values
$option_values = [];
foreach ($options as $option) {
    if ($option->type == 'radio' || $option->type == 'select') {
        $option_values[$option->id] = $option->config[array_rand($option->config)];
        $I->selectOption('option[' . $option->id . ']', $option_values[$option->id]);
    } else {
        $option_values[$option->id] = "Testing";
        $I->fillField('option[' . $option->id . ']', "Testing");
    }
}
// Submit the form
$I->submitForm('#addToCart', ['option[' . $unrelatedOption->id . ']' => $unrelatedOption->config[0]]);
$I->seeCurrentRouteIs('shop.cart.show');
// Check that we see the product
开发者ID:dan-powell,项目名称:shop,代码行数:31,代码来源:AddCartWithOptionsCept.php

示例2: FunctionalTester

<?php

$I = new FunctionalTester($scenario);
$I->wantTo('Add a product to cart that has bad extras');
// Create the models
$product = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'inStock', 1);
// Extra 1 - This extra has a few options and will be selected
$extra1 = $I->makeModel(DanPowell\Shop\Models\Extra::class, [], 'inStock', 1);
$extra1 = $product->extras()->save($extra1);
$option1 = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'text', 1);
$option1 = $extra1->options()->save($option1);
$I->amOnRoute('shop.product.show', $product->slug);
// Select the extra 1, but DON'T fill out the option value
$I->checkOption('extra[' . $extra1->id . ']');
$I->submitForm('#addToCart', []);
$I->dontSee('Product added to cart', '.alert');
$I->seeCurrentRouteIs('shop.product.show');
$I->seeFormHasErrors();
开发者ID:dan-powell,项目名称:shop,代码行数:18,代码来源:AddCartWithBadExtrasCept.php

示例3: FunctionalTester

<?php

$I = new FunctionalTester($scenario);
$I->wantTo('Add a product to cart that has extras with options');
// Create the models
$product = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'inStock', 1);
// Extra 1 - This extra has a few options and will be selected
$extra1 = $I->makeModel(DanPowell\Shop\Models\Extra::class, [], 'inStock', 1);
$extra1 = $product->extras()->save($extra1);
$options1[] = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'radio', 1);
$options1[] = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'select', 1);
$options1[] = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'text', 1);
$options1 = $extra1->options()->saveMany($options1);
// Extra 2 - This extra will not be selected
$extra2 = $I->makeModel(DanPowell\Shop\Models\Extra::class, [], 'inStock', 1);
$extra2 = $product->extras()->save($extra2);
$options2[] = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'radio', 1);
$options2[] = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'select', 1);
$options2 = $extra2->options()->saveMany($options2);
$I->amOnRoute('shop.product.show', $product->slug);
// Select the extra 1
$I->checkOption('extra[' . $extra1->id . ']');
// Select some options to make sure they appear in the cart
$option_values = [];
foreach (array_merge($options1, $options2) as $option) {
    if ($option->type == 'radio' || $option->type == 'select') {
        $option_values[$option->id] = $option->config[array_rand($option->config)];
        $I->selectOption('option[' . $option->id . ']', $option_values[$option->id]);
    } else {
        $option_values[$option->id] = "Testing";
        $I->fillField('option[' . $option->id . ']', "Testing");
开发者ID:dan-powell,项目名称:shop,代码行数:31,代码来源:AddCartWithExtrasWithOptionsCept.php

示例4: FunctionalTester

<?php

$I = new FunctionalTester($scenario);
$I->wantTo('Create an order');
// Add a product to the cart
$product = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'published', 1);
$I->amOnRoute('shop.product.show', $product->slug);
$I->click('Add to Cart');
// Checkout
$I->click('Checkout');
$order = $I->makeModel(DanPowell\Shop\Models\Order::class, [], null, 1);
$I->submitForm('#createOrder', $order->toArray());
$I->seeCurrentRouteIs('shop.order.confirm');
// Continue to confirmation
//$I->click('Continue to confirmation');
// Check delivery option exists in config
// Check delivery option matches cart total
// Check billing & delivery country exists in config
开发者ID:dan-powell,项目名称:shop,代码行数:18,代码来源:CreateOrderCept.php

示例5: FunctionalTester

<?php

$I = new FunctionalTester($scenario);
$I->wantTo('Add a product to cart that has extras');
// Create a Product and add some Extras
$product = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'inStock', 1);
for ($i = 0; $i < 2; $i++) {
    $extras[] = $I->makeModel(DanPowell\Shop\Models\Extra::class, [], 'inStock', 1);
}
$product->extras()->saveMany($extras);
// Create another product so we can try and force it's option on to the 'correct' product
$unrelatedProduct = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'inStock', 1);
$unrelatedExtra = $I->makeModel(DanPowell\Shop\Models\Extra::class, [], 'inStock', 1);
$unrelatedProduct->extras()->save($unrelatedExtra);
// Go to the product page
$I->amOnRoute('shop.product.show', $product->slug);
// Select only the first Extra
$I->checkOption('extra[' . $extras[0]->id . ']');
$I->submitForm('#addToCart', ['extra[' . $unrelatedExtra->id . ']' => 'on']);
$I->seeCurrentRouteIs('shop.cart.show');
$I->see('Product added to cart', '.alert');
$I->see($product->title, '.CartTable-product-title');
// Should see first Extra
$I->see($extras[0]->title, '.CartTable-item-extras');
// Should *not* see any other Extras
$I->dontSee($extras[1]->title, '.CartTable-item-extas');
$I->dontSee($unrelatedExtra->title, '.CartTable-item-extas');
开发者ID:dan-powell,项目名称:shop,代码行数:27,代码来源:AddCartWithExtrasCept.php


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