本文整理汇总了PHP中Way\Tests\Factory::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::create方法的具体用法?PHP Factory::create怎么用?PHP Factory::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Way\Tests\Factory
的用法示例。
在下文中一共展示了Factory::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetMostViewed
public function testGetMostViewed()
{
$user = Factory::create('User');
$this->be($user);
$snippets = array();
$tag = Factory::create('Tag');
// create 3 approved snippets
for ($i = 0; $i < 3; $i++) {
$snippets[] = Factory::create('Snippet', array('author_id' => $user->id, 'approved' => 1, 'deleted_at' => null));
}
$redis = App::make('redis');
// add 10 hits in snippet[1]
$redis->zIncrBy('hits', 10, $snippets[1]->id);
// add 5 hits in snippet[2]
$redis->zIncrBy('hits', 5, $snippets[2]->id);
// add 1 hit in snippet[0]
$redis->zIncrBy('hits', 1, $snippets[0]->id);
// expected ranking:
// 1. $snippets[1]
// 2. $snippets[2]
// 3. $snippets[0]
$snippetRepo = new EloquentSnippetRepository(new Snippet(), $this->app->make('LaraSnipp\\Repo\\Tag\\TagRepositoryInterface'), $this->app->make('LaraSnipp\\Repo\\User\\UserRepositoryInterface'));
$snippetsResult = $snippetRepo->getMostViewed();
$this->assertEquals($snippets[1], $snippetsResult[0]);
}
示例2: testHomePageTopSnippetContributors
public function testHomePageTopSnippetContributors()
{
// with 2 approved and 1 not yet approved snippet
$user = Factory::create('User', array('active' => 1));
$this->be($user);
Factory::create('Snippet', array('author_id' => $user->id, 'approved' => 1, 'deleted_at' => null));
Factory::create('Snippet', array('author_id' => $user->id, 'approved' => 1, 'deleted_at' => null));
Factory::create('Snippet', array('author_id' => $user->id, 'approved' => 0, 'deleted_at' => null));
// with 1 not yet approved snippet
$secondUser = Factory::create('User', array('active' => 1));
$this->be($secondUser);
Factory::create('Snippet', array('author_id' => $secondUser->id, 'approved' => 0, 'deleted_at' => null));
// with 1 approved and 3 not yet approved snippets
$thirdUser = Factory::create('User', array('active' => 1));
$this->be($thirdUser);
Factory::create('Snippet', array('author_id' => $thirdUser->id, 'approved' => 1, 'deleted_at' => null));
Factory::create('Snippet', array('author_id' => $thirdUser->id, 'approved' => 0, 'deleted_at' => null));
Factory::create('Snippet', array('author_id' => $thirdUser->id, 'approved' => 0, 'deleted_at' => null));
Factory::create('Snippet', array('author_id' => $thirdUser->id, 'approved' => 0, 'deleted_at' => null));
$response = $this->call('GET', '/');
$view = $response->original;
// only 2 is expected since we are only rendering contributors w/ approved snippets
$this->assertEquals(count($view['topSnippetContributors']), 2);
# rank 1 should be $user
$this->assertEquals($view['topSnippetContributors'][0]->full_name, $user->full_name);
$this->assertEquals($view['topSnippetContributors'][0]->snippets_count, 2);
# rank 2 should be $thirdUser
$this->assertEquals($view['topSnippetContributors'][1]->full_name, $thirdUser->full_name);
$this->assertEquals($view['topSnippetContributors'][1]->snippets_count, 1);
}
示例3: test_validacion_exitosa_con_clave_foranea_lugar
public function test_validacion_exitosa_con_clave_foranea_lugar()
{
$padre = Factory::create('App\\Lugar');
$lugar = Factory::attributesFor('App\\Lugar', ['lug_abreviatura' => 'asd', 'lug_nombre' => 'asd', 'lug_tipo' => 'pais', 'parent_lug_id' => $padre->lug_id]);
$validator = Validator::make($lugar, $this->rules, $this->messages);
$this->assertTrue($validator->passes(), 'Se esperaba que falle la validadicon.');
}
示例4: 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']));
}
示例5: testInvalidLoginUsingWrongCredentials
public function testInvalidLoginUsingWrongCredentials()
{
$user = Factory::create('User', array('password' => 'admin', 'active' => 1));
$inputs = array('username' => $user->username, 'password' => 'wrong password');
$crawler = $this->client->request('POST', route('auth.postLogin', $inputs));
$this->assertRedirectedToRoute('auth.getLogin');
$this->assertSessionHas('message', 'Wrong username or password');
}
示例6: testGetAdminAddTypes
public function testGetAdminAddTypes()
{
Factory::create('Giftertipster\\Entity\\Eloquent\\AddType', ['label' => 'foobar']);
Factory::create('Giftertipster\\Entity\\Eloquent\\AddType', ['label' => 'admin-foobar']);
$response = $this->repo->getAdminAddTypes();
assertThat($response[0], hasKeyValuePair('label', 'admin-foobar'));
assertThat($response[0], hasKeyValuePair('id', 2));
}
示例7: testGetShowRendersApprovedSnippets
public function testGetShowRendersApprovedSnippets()
{
$user = Factory::create('User');
$this->be($user);
$snippet = Factory::create('Snippet', array('author_id' => $user->id, 'approved' => 1, 'deleted_at' => null));
$response = $this->call('GET', route('snippet.getShow', $snippet->slug));
$this->assertResponseOk();
$view = $response->original;
$this->assertEquals($view['snippet']->title, $snippet->title);
}
示例8: testGetMySnippetsRendersApprovedAndNotYetApprovedSnippets
public function testGetMySnippetsRendersApprovedAndNotYetApprovedSnippets()
{
$user = Factory::create('User');
$this->be($user);
$notYetApprovedSnippet = Factory::create('Snippet', array('author_id' => $user->id, 'approved' => 0, 'deleted_at' => null));
$approvedSnippet = Factory::create('Snippet', array('author_id' => $user->id, 'approved' => 1, 'deleted_at' => null));
$response = $this->call('GET', route('member.user.dashboard'));
$view = $response->original;
$this->assertEquals(count($view['my_snippets']), 2);
}
示例9: test_validacion_exitosa
public function test_validacion_exitosa()
{
Factory::create('App\\Lugar', ['lug_id' => 1]);
Factory::create('App\\TipoTorneo', ['ttr_id' => 1]);
Factory::create('App\\Equipo', ['eqp_id' => 1, 'lug_id' => 1]);
Factory::create('App\\Jugador', ['jug_id' => 1, 'jug_nacionalidad' => 1]);
Factory::create('App\\Torneo', ['tor_id' => 1, 'lug_id' => 1, 'ttr_id' => 1]);
$plantillaTorneo = Factory::attributesFor('App\\PlantillaTorneo', ['plt_numero_camiseta' => 1, 'eqp_id' => 1, 'jug_id' => 1, 'tor_id' => 1]);
$validator = Validator::make($plantillaTorneo, $this->rules, $this->messages);
$this->assertTrue($validator->passes(), 'Se esperaba que la validadicon sea exitosa.');
}
示例10: testGetTrustedSitesByRealm
public function testGetTrustedSitesByRealm()
{
$realm = 'https://*.test.com';
$service = $this->app[OpenIdServiceCatalog::TrustedSitesService];
$user = Factory::create('auth\\User');
$res = $service->addTrustedSite($user, $realm, IAuthService::AuthorizationResponse_AllowForever, $data = array('email', 'profile', 'address'));
$this->assertTrue(!is_null($res));
$sites = $service->getTrustedSites($user, 'https://www.dev.test.com', $data = array('email', 'address'));
$this->assertTrue(is_array($sites));
$this->assertTrue(count($sites) > 0);
}
示例11: testGetShowOnlyRendersApprovedSnippets
public function testGetShowOnlyRendersApprovedSnippets()
{
$user = Factory::create('User');
$this->be($user);
$notYetApprovedSnippet = Factory::create('Snippet', array('author_id' => $user->id, 'approved' => 0, 'deleted_at' => null));
$approvedSnippet = Factory::create('Snippet', array('author_id' => $user->id, 'approved' => 1, 'deleted_at' => null));
$response = $this->call('GET', route('snippet.getIndex'));
$view = $response->original;
$this->assertEquals(count($view['snippets']), 1);
$this->assertEquals($approvedSnippet->title, $view['snippets'][0]->title);
}
示例12: testGetUnfulfilledRequestsReturnsFalseWhenAllRequestsAreFulfilled
public function testGetUnfulfilledRequestsReturnsFalseWhenAllRequestsAreFulfilled()
{
Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
$seed_request1 = Factory::create('Giftertipster\\Entity\\Eloquent\\ProductDeleteRequest', ['user_id' => 1, 'product_id' => 1, 'is_fulfilled' => 1, 'delete_type' => 'delete']);
$seed_request2 = Factory::create('Giftertipster\\Entity\\Eloquent\\ProductDeleteRequest', ['user_id' => 1, 'product_id' => 2, 'is_fulfilled' => 1, 'delete_type' => 'delete']);
$repo = $this->app->make('Giftertipster\\Repository\\ProductDeleteRequest\\EloquentProductDeleteRequestRepository');
$requests = $repo->getUnfulfilledRequests();
assertThat($requests, identicalTo(false));
}
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:11,代码来源:EloquentProductDeleteRequestRepositoryTest.php
示例13: testCreateFailsIfIdeaAlreadyExistsAndReturnsFalseWithErrors
public function testCreateFailsIfIdeaAlreadyExistsAndReturnsFalseWithErrors()
{
Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
$idea_repo = $this->app->make('Giftertipster\\Repository\\Idea\\EloquentIdeaRepository');
$new_idea = 'blender';
$response = $idea_repo->create(['user_id' => 1, 'description' => $new_idea, 'is_fulfilled' => 0]);
$idea = $this->eloquent_idea->find(1);
$response = $idea_repo->create(['user_id' => 1, 'description' => $new_idea, 'is_fulfilled' => 0]);
$errors = $idea_repo->errors();
assertThat($response, identicalTo(false));
assertThat($errors->first(), equalTo('The description has already been taken.'));
}
示例14: testGetSnippets
public function testGetSnippets()
{
$user = Factory::create('User', array('active' => 1));
$this->be($user);
$notYetApprovedSnippet = Factory::create('Snippet', array('author_id' => $user->id, 'approved' => 0, 'deleted_at' => null));
$approvedSnippet = Factory::create('Snippet', array('author_id' => $user->id, 'approved' => 1, 'deleted_at' => null));
$response = $this->call('GET', route('user.getSnippets', $user->slug));
$this->assertResponseOk();
$view = $response->original;
# should be 1 because only 1 submitted snippet of $user is approved
$this->assertEquals(1, count($view['snippets']));
$this->assertViewHas('user');
}
示例15: 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()));
}