本文整理汇总了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);
}
示例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());
}
}
示例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']);
}
示例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]);
}
示例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]);
}
示例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));
}
示例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']);
}
示例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);
}
示例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');
}
示例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);
}
示例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');
}
示例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));
}
示例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);
}
示例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');
}
示例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));
}
}