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


PHP Tests\Factory类代码示例

本文整理汇总了PHP中Way\Tests\Factory的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: 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.');
 }
开发者ID:00dav00,项目名称:marcadores-minimal,代码行数:7,代码来源:LugarRequestTest.php

示例2: 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]);
 }
开发者ID:kcsamita,项目名称:laravelsnippets,代码行数:25,代码来源:EloquentSnippetRepositoryTest.php

示例3: 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);
 }
开发者ID:kcsamita,项目名称:laravelsnippets,代码行数:30,代码来源:HomeControllerTest.php

示例4: 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));
 }
开发者ID:sorora,项目名称:aurp,代码行数:7,代码来源:UsersControllerTest.php

示例5: test_validacion_exitosa_con_formato_de_url

 public function test_validacion_exitosa_con_formato_de_url()
 {
     $clienteFake = factory(App\Cliente::class)->make();
     $cliente = Factory::attributesFor('App\\Cliente', ['clt_nombre' => $clienteFake->clt_nombre, 'clt_descripcion' => '', 'clt_dominio' => $clienteFake->clt_dominio]);
     $validator = Validator::make($cliente, ClienteRequest::$rules, ClienteRequest::$messages);
     $this->assertTrue($validator->passes(), 'Se esperaba que la validacion de url sea exitosa.');
 }
开发者ID:00dav00,项目名称:marcadores-minimal,代码行数:7,代码来源:ClienteRequestTest.php

示例6: test_validacion_exitosa

 public function test_validacion_exitosa()
 {
     $equipo = factory(App\Equipo::class)->create();
     $fase = factory(App\Fase::class)->create();
     $penalizacion = Factory::attributesFor('App\\PenalizacionTorneo', ['eqp_id' => $equipo->eqp_id, 'fas_id' => $fase->fas_id, 'ptr_puntos' => 1, 'ptr_motivo' => 'asd']);
     $validator = Validator::make($penalizacion, $this->rules, $this->messages);
     $this->assertTrue($validator->passes(), 'Se esperaba que la validadicon sea exitosa.');
 }
开发者ID:00dav00,项目名称:marcadores-minimal,代码行数:8,代码来源:PenalizacionTorneoRequestTest.php

示例7: 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));
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:8,代码来源:EloquentAddTypeRepositoryTest.php

示例8: 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']));
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:8,代码来源:EloquentKeywordProfileRepositoryTest.php

示例9: 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');
 }
开发者ID:kcsamita,项目名称:laravelsnippets,代码行数:8,代码来源:AuthControllerTest.php

示例10: 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);
 }
开发者ID:kcsamita,项目名称:laravelsnippets,代码行数:10,代码来源:UserControllerTest.php

示例11: 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'));
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:10,代码来源:RangeCronJobTest.php

示例12: 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);
 }
开发者ID:kcsamita,项目名称:laravelsnippets,代码行数:10,代码来源:SnippetControllerTest.php

示例13: 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'));
 }
开发者ID:sorora,项目名称:aurp,代码行数:10,代码来源:PermissionTest.php

示例14: 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);
 }
开发者ID:kcsamita,项目名称:laravelsnippets,代码行数:11,代码来源:TagControllerTest.php

示例15: 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


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