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


PHP Factory::times方法代码示例

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


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

示例1: testDestroyReturnsJsonResponseInstance

 public function testDestroyReturnsJsonResponseInstance()
 {
     $users = Factory::times(5)->create('App\\User');
     $currentUser = User::first();
     Auth::login($currentUser);
     $controller = new FriendController($currentUser);
     $request = new Request(['userId' => 2]);
     $response = $controller->destroy($request);
     $this->assertInstanceOf('Illuminate\\Http\\JsonResponse', $response);
 }
开发者ID:talha08,项目名称:Larasocial,代码行数:10,代码来源:TestFriendController.php

示例2: testSuccessLeagueDrawWithDifferrentTeamsAmount

 /**
  * @param $teamsAmount
  * @param $matcheAmount
  *
  * @dataProvider tournamentTeamsProvider
  */
 public function testSuccessLeagueDrawWithDifferrentTeamsAmount($teamsAmount, $matchesAmount)
 {
     /**
      * @var $tournament Tournament
      */
     $tournament = Factory::create('App\\Models\\Tournament');
     /**
      * @var $tournament Tournament
      */
     $league = Factory::create('App\\Models\\League');
     Factory::times($teamsAmount)->create('App\\Models\\Team', ['leagueId' => $league->id])->each(function ($team, $key) use($tournament) {
         $tournament->tournamentTeams()->create(['teamId' => $team->id, 'tournamentId' => $tournament->id]);
     });
     $tournament->status = Tournament::STATUS_STARTED;
     $tournament->save();
     $this->assertTrue($tournament instanceof Tournament);
     // verify total matches amount
     $this->assertEquals($matchesAmount, $tournament->matches()->getResults()->count());
     /**
      * @var $matches Collection
      * @var $team TournamentTeam
      */
     $matches = Match::where(['tournamentId' => $tournament->id])->get();
     foreach ($tournament->tournamentTeams()->getResults() as $team) {
         // verify matches per team
         $this->assertEquals(($teamsAmount - 1) * 2, $matches->filter(function ($match) use($team) {
             return $match->homeTournamentTeamId == $team->id || $match->awayTournamentTeamId == $team->id;
         })->count());
     }
 }
开发者ID:bashmach,项目名称:ggf,代码行数:36,代码来源:DrawLeagueTest.php

示例3: run

 public function run()
 {
     TestDummy::times(1)->create('Bican\\Roles\\Models\\Permission');
     Permission::create(['name' => 'Manager', 'slug' => 'Manager', 'description' => 'Reporting to Board']);
     Permission::create(['name' => 'Admin', 'slug' => preg_replace('/[\\s-]+/', '-', "admin"), 'description' => 'Reporting to Manager']);
     Permission::create(['name' => 'Trainee', 'slug' => "Trainee", 'description' => 'Reporting to Admin']);
 }
开发者ID:qbana,项目名称:printon,代码行数:7,代码来源:PermissionsTableSeeder.php

示例4: it_unfollows_another_user

 /** @test */
 public function it_unfollows_another_user()
 {
     $users = TestDummy::times(2)->create('Larabook\\Users\\User');
     $this->repo->follow($users[1]->id, $users[0]);
     $this->repo->unfollow($users[1]->id, $users[0]);
     $this->tester->dontSeeRecord('follows', ['follower_id' => $users[0]->id, 'followed_id' => $users[1]->id]);
 }
开发者ID:atolver,项目名称:larabook,代码行数:8,代码来源:UserRepositoryTest.php

示例5: it_unfollows_another_user

 /** @test */
 public function it_unfollows_another_user()
 {
     list($john, $susan) = TestDummy::times(2)->create('Larabook\\Users\\User');
     $this->repo->follow($susan->id, $john);
     $this->repo->unfollow($susan->id, $john);
     $this->tester->dontseeRecord('follows', ['follower_id' => $john->id, 'followed_id' => $susan->id]);
 }
开发者ID:billwaddyjr,项目名称:larabook-2,代码行数:8,代码来源:UserRepositoryTest.php

示例6: testGetIdsThatSentRequestToCurrentUser

 public function testGetIdsThatSentRequestToCurrentUser()
 {
     $user = Factory::create('App\\User');
     $friendRequests = Factory::times(25)->create('App\\FriendRequest', ['user_id' => $user->id]);
     $repository = new EloquentFriendRequestRepository();
     $results = $repository->getIdsThatSentRequestToCurrentUser($user->id);
     $this->assertEquals(25, count($results));
 }
开发者ID:aku345,项目名称:Larasocial,代码行数:8,代码来源:TestFriendRequestRepository.php

示例7: run

 public function run()
 {
     TestDummy::times(1)->create('Bican\\Roles\\Models\\Role');
     Role::create(['name' => 'Printeron', 'slug' => 'Printeron', 'description' => 'Dostep tylko dla pracownikow Printon', 'level' => '40']);
     Role::create(['name' => 'Printing House', 'slug' => preg_replace('/[\\s-]+/', '-', 'Printing House'), 'description' => 'Drukarnia', 'level' => '30']);
     Role::create(['name' => 'Advertising Agency', 'slug' => "Advertising-Agency", 'description' => 'Dostep tylko dla Agencji reklamowych', 'level' => '20']);
     Role::create(['name' => 'Client', 'slug' => "Client", 'description' => 'Klient', 'level' => '10']);
 }
开发者ID:qbana,项目名称:printon,代码行数:8,代码来源:RolesTableSeeder.php

示例8: it_finds_users_with_statuses_by_their_username

 /** @test */
 public function it_finds_users_with_statuses_by_their_username()
 {
     $statuses = TestDummy::times(3)->create('Larabook\\Statuses\\Status');
     $username = $statuses[0]->user->username;
     $user = $this->repo->findByUsername($username);
     $this->assertEquals($username, $user->username);
     $this->assertCount(3, $user->statuses);
 }
开发者ID:billwaddyjr,项目名称:laracasts,代码行数:9,代码来源:UserRepositoryTest.php

示例9: testIndex

 public function testIndex()
 {
     $projects = Factory::times(2)->create('Project');
     $this->action('GET', 'ProjectsController@index');
     $this->assertResponseOk();
     $this->assertViewIs('projects.index');
     $this->assertViewHas('projects');
 }
开发者ID:riehlemt,项目名称:neontsunami,代码行数:8,代码来源:ProjectsControllerTest.php

示例10: it_gets_all_statuses_for_a_user

 /**
  * @test
  */
 public function it_gets_all_statuses_for_a_user()
 {
     $user = TestDummy::times(2)->create('App\\User');
     TestDummy::times(2)->create('App\\Status', ['user_id' => $user[0]->id]);
     TestDummy::times(2)->create('App\\Status', ['user_id' => $user[1]->id]);
     $statusesForUser = $this->repo->getAllForUser($user[0]);
     $this->assertCount(2, $statusesForUser);
 }
开发者ID:rolandtacadena,项目名称:larabook-updated,代码行数:11,代码来源:StatusRepositoryTest.php

示例11: run

 public function run()
 {
     DB::table('user')->delete();
     TestDummy::create('normal_user');
     TestDummy::create('editor_user');
     TestDummy::create('admin_user');
     TestDummy::times(20)->create('WITR\\User');
 }
开发者ID:woolensculpture,项目名称:pulse,代码行数:8,代码来源:UserTableSeeder.php

示例12: testGetPublishedByUserAndFriendsAjaxReturnArrayWithResults

 public function testGetPublishedByUserAndFriendsAjaxReturnArrayWithResults()
 {
     $user = Factory::create('App\\User');
     $feeds = Factory::times(20)->create('App\\Feed', ['user_id' => $user->id]);
     $repository = new EloquentFeedRepository();
     $feedCount = $repository->getPublishedByUserAndFriends($user);
     $this->assertEquals(10, count($feedCount));
 }
开发者ID:aku345,项目名称:Larasocial,代码行数:8,代码来源:TestFeedRepository.php

示例13: run

 public function run()
 {
     $this->truncateTable('property_types');
     $propertyTypes = config('setup.properties.types');
     foreach ($propertyTypes as $id => $propertyType) {
         PropertyType::create(['id' => $propertyType['id'], 'name' => $propertyType['name'], 'element' => $propertyType['element'], 'type' => $propertyType['type'], 'is_void' => $propertyType['is_void']]);
     }
     Factory::times(10)->create(PropertyType::class);
 }
开发者ID:creativify,项目名称:kraken,代码行数:9,代码来源:PropertyTypesTableSeeder.php

示例14: testIndex

 public function testIndex()
 {
     Factory::times(2)->create('Post');
     $this->action('GET', 'PagesController@index');
     $this->assertResponseOk();
     $this->assertViewIs('pages.index');
     $this->assertViewHas('latestPost');
     $this->assertViewHas('popularPosts');
 }
开发者ID:riehlemt,项目名称:neontsunami,代码行数:9,代码来源:PagesControllerTest.php

示例15: testReceiptCategoryAssign

 /**
  * A functional test example.
  *
  * @return void
  */
 public function testReceiptCategoryAssign()
 {
     $receipt = Factory::create('App\\Receipt');
     $categories = Factory::times(3)->create('App\\Category');
     $owner = ['user_id' => \App\User::first()->id];
     $receipt->categories()->attach($categories->lists('id'), $owner);
     foreach ($categories as $category) {
         $this->assertTrue($receipt->hasCategory($category));
     }
 }
开发者ID:hootlex,项目名称:apodeiksi,代码行数:15,代码来源:CategoriseReceiptsTest.php


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