本文整理汇总了PHP中Way\Tests\Factory::make方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::make方法的具体用法?PHP Factory::make怎么用?PHP Factory::make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Way\Tests\Factory
的用法示例。
在下文中一共展示了Factory::make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEdit
public function testEdit()
{
$this->mock->shouldReceive('with')->with('role')->andReturn($this->mock);
$this->mock->shouldReceive('findOrFail')->with(3)->once()->andReturn(Factory::make($this->factory, array('id' => 3)));
$this->get($this->url . '/3/edit', 3);
$this->assertViewHas(substr($this->var, 0, -1));
}
示例2: testGetAnalytics
public function testGetAnalytics()
{
//load analytics into DB
Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
$occasion1 = Factory::create('Giftertipster\\Entity\\Eloquent\\Category\\OccasionCategory', ['label' => 'foobar1', 'icon_name' => 'icon1', 'priority' => 1]);
$occasion2 = Factory::create('Giftertipster\\Entity\\Eloquent\\Category\\OccasionCategory', ['label' => 'foobar2', 'icon_name' => 'icon2', 'priority' => 1]);
//$occasion3 = Factory::create('Giftertipster\Entity\Eloquent\Category\OccasionCategory', ['label' => 'foobar5', 'icon_name' => 'icon5', 'priority' => 1]);
//$occasion4 = Factory::create('Giftertipster\Entity\Eloquent\Category\OccasionCategory', ['label' => 'foobar6', 'icon_name' => 'icon6', 'priority' => 1]);
Factory::create('Giftertipster\\Entity\\Eloquent\\Analytic\\UserAnalytic', ['user_id' => 1, 'quantity' => 2]);
Factory::create('Giftertipster\\Entity\\Eloquent\\Analytic\\UserAnalytic', ['user_id' => 2, 'quantity' => 8]);
Factory::create('Giftertipster\\Entity\\Eloquent\\Analytic\\UserAnalytic', ['user_id' => 3, 'quantity' => 0]);
$cat_analytic1 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 1, 'category_type' => null, 'category_id' => null, 'quantity' => 1]);
$cat_analytic2 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 1, 'category_type' => null, 'category_id' => null, 'quantity' => 2]);
$cat_analytic3 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 2, 'category_type' => null, 'category_id' => null, 'quantity' => 5]);
$cat_analytic4 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 2, 'category_type' => null, 'category_id' => null, 'quantity' => 6]);
$cat_analytic5 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 3, 'category_type' => null, 'category_id' => null, 'quantity' => 0]);
$cat_analytic6 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 3, 'category_type' => null, 'category_id' => null, 'quantity' => 0]);
$occasion1->categoryAnalytics()->save($cat_analytic1);
$occasion2->categoryAnalytics()->save($cat_analytic2);
$occasion1->categoryAnalytics()->save($cat_analytic3);
$occasion2->categoryAnalytics()->save($cat_analytic4);
$occasion1->categoryAnalytics()->save($cat_analytic5);
$occasion2->categoryAnalytics()->save($cat_analytic6);
//expected results
$expected_analytics = ['_users' => [1 => ['occasion_categories' => [1 => ['quantity' => 1, 'total_quantity' => 2, 'percentage_of_total' => 50.0], 2 => ['quantity' => 2, 'total_quantity' => 2, 'percentage_of_total' => 100.0]]], 2 => ['occasion_categories' => [1 => ['quantity' => 5, 'total_quantity' => 8, 'percentage_of_total' => 62.0], 2 => ['quantity' => 6, 'total_quantity' => 8, 'percentage_of_total' => 75.0]]], 3 => ['occasion_categories' => [1 => ['quantity' => 0, 'total_quantity' => 0, 'percentage_of_total' => 0], 2 => ['quantity' => 0, 'total_quantity' => 0, 'percentage_of_total' => 0]]]], '_all' => ['occasion_categories' => [1 => ['quantity' => 6, 'total_quantity' => 10, 'percentage_of_total' => 60.0], 2 => ['quantity' => 8, 'total_quantity' => 10, 'percentage_of_total' => 80.0]]]];
assertThat($this->repo->getCategoryAnalytics(), identicalTo($expected_analytics));
}
示例3: testIsInvalidWhenAddTypeIdDoesntExist
public function testIsInvalidWhenAddTypeIdDoesntExist()
{
Factory::create('Giftertipster\\Entity\\Eloquent\\AddType');
Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
$add = Factory::make('Giftertipster\\Entity\\Eloquent\\Add', ['product_id' => 1, 'add_type_id' => 5]);
$this->assertNotValid($add);
}
示例4: test_edit_devuelve_tipotorneo
public function test_edit_devuelve_tipotorneo()
{
$tipo_torneo = Factory::make('App\\TipoTorneo', ['ttr_nombre' => 'Ecuador']);
$this->modelMock->shouldReceive('findOrFail')->once()->andReturn($tipo_torneo);
$this->app->instance('App\\TipoTorneo', $this->modelMock);
$response = $this->call('GET', '/tipo_torneo/1/edit');
$this->assertViewHas('tipo_torneo', $tipo_torneo);
}
示例5: testUpdateForProduct
public function testUpdateForProduct()
{
$product = Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
$keyword_profile = Factory::make('Giftertipster\\Entity\\Eloquent\\KeywordProfile');
$product->keywordProfile()->save($keyword_profile);
$this->repo->updateForProduct(1, ['profile' => ['updated', 'profile']]);
assertThat(KeywordProfile::find(1)->profile, identicalTo(['updated', 'profile']));
}
示例6: testFillableAndGuardedAttributes
public function testFillableAndGuardedAttributes()
{
$product = Factory::make('Giftertipster\\Entity\\Eloquent\\RangeCronJob');
assertThat($product['guarded'], hasItemInArray('id'));
assertThat($product['guarded'], hasItemInArray('created_at'));
assertThat($product['guarded'], hasItemInArray('updated_at'));
assertThat($product['fillable'], hasItemInArray('job_name'));
assertThat($product['fillable'], hasItemInArray('last_id_processed'));
assertThat($product['fillable'], hasItemInArray('last_status'));
}
示例7: testUsesRoleReturnsPermissionsArray
public function testUsesRoleReturnsPermissionsArray()
{
$mock = Mockery::mock('Sorora\\Aurp\\Models\\Role');
$mock->shouldReceive('load')->with('permissions')->once();
$permissions = array(Factory::make('Sorora\\Aurp\\Models\\' . $this->model, array('id' => 1, 'task' => 'Foo')), Factory::make('Sorora\\Aurp\\Models\\' . $this->model, array('id' => 5, 'task' => 'Bar')));
$mock->shouldReceive('getAttribute')->once()->andReturn((object) $permissions);
$item = new Permission();
$permissions = $item->usesRole($mock);
$this->assertEquals($permissions, array(1 => 'Foo', 5 => 'Bar'));
}
示例8: testSubProductForCartAddWorks
public function testSubProductForCartAddWorks()
{
$sub_product = Factory::create('Giftertipster\\Entity\\Eloquent\\SubProduct', ['id' => 1, 'vendor_id' => 'asin stub', 'offer_listing_id' => 'offer listing id stub']);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['category' => 'variation']);
$image2 = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['category' => 'primary']);
$sub_product->images()->save($image);
$sub_product->images()->save($image2);
$sub_product2 = Factory::create('Giftertipster\\Entity\\Eloquent\\SubProduct');
$sub_product_repo = $this->app->make('Giftertipster\\Repository\\SubProduct\\EloquentSubProductRepository');
$result_sub_product = $sub_product_repo->subProductDataForCartAdd(1);
assertThat($result_sub_product, hasKeyValuePair('id', 1));
assertThat($result_sub_product, hasKey('images'));
assertThat($result_sub_product['images'], not(emptyArray()));
}
示例9: testIsInvalidIfIsRefreshedIsNot1Or0
public function testIsInvalidIfIsRefreshedIsNot1Or0()
{
$invalid_value = 3;
$product = Factory::make('Giftertipster\\Entity\\Eloquent\\Product', ['is_refreshed' => $invalid_value]);
$this->assertNotValid($product);
}
示例10: testFilterProductsReturnsProductsSortedPerIndexResponse
public function testFilterProductsReturnsProductsSortedPerIndexResponse()
{
$index_response_stub = ['meta' => ['total_hits' => 2], 'results' => [['_id' => 2], ['_id' => 1]], 'facets' => ['foobar']];
$find_many_params_stub = [2, 1];
$product_suite_response = new \Illuminate\Database\Eloquent\Collection();
$product_suite_response->add(Factory::make('Giftertipster\\Entity\\Eloquent\\Product', ['id' => 2, 'title' => 'foobar title']));
$product_suite_response->add(Factory::make('Giftertipster\\Entity\\Eloquent\\Product', ['id' => 1, 'title' => 'foobar title']));
$expected_response = ['meta' => ['total_hits' => 2], 'results' => [['is_refreshed' => 1, 'id' => 2, 'title' => 'foobar title'], ['is_refreshed' => 1, 'id' => 1, 'title' => 'foobar title']], 'facets' => ['foobar']];
$index_repo_mock = Mockery::mock('Giftertipster\\Repository\\ProductsIndex\\Product\\ProductsIndexProductRepositoryInterface');
$index_repo_mock->shouldReceive('filterProducts')->with(0, 2, ['FilterName' => ['filter params' => 'foobar']])->once()->andReturn($index_response_stub);
$this->app->instance('Giftertipster\\Repository\\ProductsIndex\\Product\\ProductsIndexProductRepositoryInterface', $index_repo_mock);
$product_suite_mock = Mockery::mock('Giftertipster\\Repository\\ProductSuite\\ProductSuiteRepositoryInterface');
$product_suite_mock->shouldReceive('findMany')->with($find_many_params_stub, true)->andReturn($product_suite_response);
$this->app->instance('Giftertipster\\Repository\\ProductSuite\\ProductSuiteRepositoryInterface', $product_suite_mock);
$this->service = $this->app->make('Giftertipster\\Service\\ProductSuite\\ProductSuiteFromIndexFetcher');
//offset, limit, array of filters
$response = $this->service->filterProducts(0, 2, ['FilterName' => ['filter params' => 'foobar']]);
assertThat($response, identicalTo($expected_response));
}
示例11: testProductMatchingAsinThrowsRunTimeExceptionWhenMoreThanOneSubProductMatches
/**
* @expectedException RuntimeException
*/
public function testProductMatchingAsinThrowsRunTimeExceptionWhenMoreThanOneSubProductMatches()
{
$product = Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
$product2 = Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
$sub_product = Factory::make('Giftertipster\\Entity\\Eloquent\\SubProduct', ['vendor_id' => 'asin stub']);
$sub_product2 = Factory::make('Giftertipster\\Entity\\Eloquent\\SubProduct', ['vendor_id' => 'asin stub']);
$product->subProducts()->save($sub_product);
$product2->subProducts()->save($sub_product2);
$calib_count = $product->has('subProducts')->get()->count();
assertThat($calib_count, equalTo(2));
$product_repo = $this->app->make('Giftertipster\\Repository\\Product\\EloquentProductRepository');
$result_product = $product_repo->productMatchingAsin('asin stub');
}
示例12: testUpdatedAtIsGuarded
public function testUpdatedAtIsGuarded()
{
$product = Factory::make('Giftertipster\\Entity\\Eloquent\\Category\\AgeCategory');
assertThat($product['guarded'], either(hasItemInArray('updated_at'))->orElse(hasItemInArray('*')));
}
示例13: testValidWithAllFields
public function testValidWithAllFields()
{
$item = Factory::make('Sorora\\Bms\\Models\\' . $this->model, array('user_id' => 1));
$this->assertValid($item);
}
示例14: testIsInvalidWhenHeightAndWidthExceedMaxValue
public function testIsInvalidWhenHeightAndWidthExceedMaxValue()
{
$invalid_input = 65536;
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['swatch_height' => $invalid_input]);
$this->assertNotValid($image);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['swatch_width' => $invalid_input]);
$this->assertNotValid($image);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['small_height' => $invalid_input]);
$this->assertNotValid($image);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['small_width' => $invalid_input]);
$this->assertNotValid($image);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['tiny_height' => $invalid_input]);
$this->assertNotValid($image);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['tiny_width' => $invalid_input]);
$this->assertNotValid($image);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['thumb_height' => $invalid_input]);
$this->assertNotValid($image);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['thumb_width' => $invalid_input]);
$this->assertNotValid($image);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['medium_height' => $invalid_input]);
$this->assertNotValid($image);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['medium_width' => $invalid_input]);
$this->assertNotValid($image);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['large_height' => $invalid_input]);
$this->assertNotValid($image);
$image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['large_width' => $invalid_input]);
$this->assertNotValid($image);
}
示例15: testIsInvalidWhenIconNameIsMoreThan100Chars
public function testIsInvalidWhenIconNameIsMoreThan100Chars()
{
Factory::make('Giftertipster\\Entity\\Eloquent\\Category\\SubInterestCategory', ['label' => 'foobar']);
$invalid_input = str_pad('a', 101);
$model = Factory::make('Giftertipster\\Entity\\Eloquent\\Category\\SubInterestCategory', ['icon_name' => $invalid_input, 'priority' => 5]);
$this->assertNotValid($model);
}