本文整理汇总了PHP中Laracasts\TestDummy\Factory类的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Factory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testUpdateMatchScore
/**
* @param $request
* @param $response
* @param $attributesToCheck
*
* @dataProvider matchUpdatesWithRequests
*/
public function testUpdateMatchScore($request, $response, $attributesToCheck)
{
$member = Factory::create('App\\Models\\Member');
Auth::login($member);
/**
* @var $tournament Tournament
* @var $league League
* @var $homeTeam Team
* @var $awayTeam Team
* @var $homeTournamentTeam TournamentTeam
* @var $awayTournamentTeam TournamentTeam
* @var $match Match
*/
$tournament = Factory::create('App\\Models\\Tournament');
$league = Factory::create('App\\Models\\League');
$homeTeam = Factory::create('App\\Models\\Team', ['leagueId' => $league->id]);
$awayTeam = Factory::create('App\\Models\\Team', ['leagueId' => $league->id]);
$homeTournamentTeam = Factory::create('App\\Models\\TournamentTeam', ['teamId' => $homeTeam->id, 'tournamentId' => $tournament->id]);
$awayTournamentTeam = Factory::create('App\\Models\\TournamentTeam', ['teamId' => $awayTeam->id, 'tournamentId' => $tournament->id]);
$match = Factory::create('App\\Models\\Match', ['tournamentId' => $tournament->id, 'homeTournamentTeamId' => $homeTournamentTeam->id, 'awayTournamentTeamId' => $awayTournamentTeam->id]);
$this->put('/api/v1/matches/' . $match->id, ['match' => $request], ['HTTP_X-Requested-With' => 'XMLHttpRequest', 'HTTP_CONTENT_TYPE' => 'application/json', 'HTTP_ACCEPT' => 'application/json']);
$this->assertResponseStatus($response['status']);
if (!empty($result)) {
$updatedRow = Match::find($match->id);
foreach ($result as $property => $value) {
$this->assertEquals($value, $updatedRow->getAttribute($property));
}
}
}
开发者ID:bashmach,项目名称:ggf,代码行数:36,代码来源:MatchTest.php
示例2: testRepoRemovePlayerSuccessRemoval
/**
* Tests if the remove function works correctly.
*/
public function testRepoRemovePlayerSuccessRemoval()
{
$player = Factory::create('App\\Models\\Player');
$success = $this->repository->removePlayer($player->nickname);
$this->assertTrue($success);
$this->assertNull(Player::find($player->id));
}
开发者ID:TiagoMaiaL,项目名称:Tournament-Manager,代码行数:10,代码来源:PlayersRepoIntgrationTest.php
示例3: testStoreWithIncorrectCredentials
public function testStoreWithIncorrectCredentials()
{
$user = Factory::create('User', ['email' => '[email protected]']);
$this->action('POST', 'Admin\\SessionsController@store', ['email' => $user->email, 'password' => 'foo']);
$this->assertRedirectedToRoute('admin.sessions.create');
$this->assertSessionHas('error', 'Your login credentials were invalid.');
}
开发者ID:riehlemt,项目名称:neontsunami,代码行数:7,代码来源:AdminSessionsControllerTest.php
示例4: testDestroy
public function testDestroy()
{
$series = Factory::create('Series');
$this->action('DELETE', 'Admin\\SeriesController@destroy', $series->slug);
$this->assertRedirectedToRoute('admin.series.index');
$this->assertEquals(0, Series::count());
}
开发者ID:riehlemt,项目名称:neontsunami,代码行数:7,代码来源:AdminSeriesControllerTest.php
示例5: makeUser
private function makeUser($overrides = [])
{
# $user = factory(User::class)->make($overrides);
$user = Factory::build('Timegridio\\Tests\\Models\\User', $overrides);
$user->email = '[email protected]';
return $user;
}
开发者ID:timegridio,项目名称:concierge,代码行数:7,代码来源:CreateUser.php
示例6: testRepoRemoveAdminSuccessRemoval
/**
* Tests if the repo removeAdministrator removes an
* admin properly.
*/
public function testRepoRemoveAdminSuccessRemoval()
{
$admin = Factory::create('App\\Models\\Administrator');
$wasDeleted = $this->repository->removeAdministrator($admin->nickname);
$this->assertTrue($wasDeleted);
$this->assertNull(Administrator::find($admin->id));
}
开发者ID:TiagoMaiaL,项目名称:Tournament-Manager,代码行数:11,代码来源:AdministratorsRepoIntegrationTest.php
示例7: makeDomain
private function makeDomain(User $owner, $overrides = [])
{
$domain = Factory::build(Domain::class, $overrides);
$domain->save();
$domain->owners()->attach($owner);
return $domain;
}
开发者ID:timegridio,项目名称:concierge,代码行数:7,代码来源:CreateDomain.php
示例8: testDestroy
public function testDestroy()
{
$user = Factory::create('User');
$this->action('DELETE', 'Admin\\UsersController@destroy', $user->id);
$this->assertRedirectedToRoute('admin.users.index');
$this->assertEquals(0, User::count());
}
开发者ID:riehlemt,项目名称:neontsunami,代码行数:7,代码来源:AdminUsersControllerTest.php
示例9: 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
示例10: testDestroy
public function testDestroy()
{
$project = Factory::create('Project');
$this->action('DELETE', 'Admin\\ProjectsController@destroy', $project->slug);
$this->assertRedirectedToRoute('admin.projects.index');
$this->assertEquals(0, Project::count());
}
开发者ID:riehlemt,项目名称:neontsunami,代码行数:7,代码来源:AdminProjectsControllerTest.php
示例11: makeBusiness
private function makeBusiness(User $owner, $overrides = [])
{
$business = Factory::build(Business::class, $overrides);
$business->save();
$business->owners()->attach($owner);
return $business;
}
开发者ID:timegridio,项目名称:concierge,代码行数:7,代码来源:CreateBusiness.php
示例12: test_it_saves_a_todo_for_a_given_todolist
public function test_it_saves_a_todo_for_a_given_todolist()
{
$todolist = Factory::create(App\Umbrella\Todo\TodoList::class, ['user_id' => 1]);
$todoRepository = $this->app->make(App\Umbrella\Todo\Repository\TodoRepositoryInterface::class);
$todo = $todoRepository->create('Finish up homework', $todolist);
$this->seeInDatabase('todo', ['name' => 'Finish up homework', 'todo_list_id' => $todolist->id]);
}
开发者ID:burimshala,项目名称:todoapp,代码行数:7,代码来源:TodoRepositoryTest.php
示例13: testUserRelationshipReturnsModel
public function testUserRelationshipReturnsModel()
{
$meta = Factory::create('PostMeta', ['meta_key' => 'pal_user_id', 'meta_value' => 1]);
Factory::create('User', ['id' => 1]);
$user = $meta->user;
assertThat($user, is(anInstanceof('User')));
}
开发者ID:estebanmatias92,项目名称:pull-automatically-galleries,代码行数:7,代码来源:PostMetaTest.php
示例14: test_it_updates_a_todo
public function test_it_updates_a_todo()
{
$todo = Factory::create(App\Umbrella\Todo\Todo::class);
$todoRepository = $this->app->make(App\Umbrella\Todo\Repository\TodoRepositoryInterface::class);
$todoRepository->update($todo, ['finished' => true]);
$this->seeInDatabase('todo', ['id' => $todo->id, 'finished' => 1]);
}
开发者ID:burimshala,项目名称:todoapp,代码行数:7,代码来源:TodoRepositoryTest.php
示例15: test_it_persists_a_todolist_for_a_given_user
public function test_it_persists_a_todolist_for_a_given_user()
{
$user = \Laracasts\TestDummy\Factory::create(App\Umbrella\User\User::class);
$todolistRepo = App::make('App\\Umbrella\\Todo\\Repository\\TodolistRepositoryInterface');
$todolist = $todolistRepo->create('Private', $user);
$this->seeInDatabase('todolist', ['name' => 'Private']);
}
开发者ID:burimshala,项目名称:todoapp,代码行数:7,代码来源:TodolistRepositoryTest.php
示例16: testSendingAmessageToAnotherUser
public function testSendingAmessageToAnotherUser()
{
$currentUser = Factory::create('App\\User');
$otherUser = Factory::create('App\\User');
Auth::login($currentUser);
$this->visit('/messages/compose/' . $otherUser->id)->submitForm('Submit', ['body' => 'This is the new message to you.'])->verifyInDatabase('messages', ['body' => 'This is the new message to you.'])->verifyInDatabase('message_responses', ['body' => 'This is the new message to you.']);
}
开发者ID:aku345,项目名称:Larasocial,代码行数:7,代码来源:MessagesTest.php
示例17: testHandleReturnsTrueOnsuccesfulLogin
public function testHandleReturnsTrueOnsuccesfulLogin()
{
$currentUser = Factory::create('App\\User');
$loginUserCommand = new LoginUserCommand($currentUser->email, $currentUser->password);
$loginUserCommand->handle();
// $this->assertTrue($response);
// $this->assertTrue($response);
}
开发者ID:aku345,项目名称:Larasocial,代码行数:8,代码来源:TestLoginUserCommand.php
示例18: 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
示例19: testHandleReturnsTheNewlyCreatedFeed
public function testHandleReturnsTheNewlyCreatedFeed()
{
$currentUser = Factory::create('App\\User');
Auth::login($currentUser);
$createFeedCommand = new CreateFeedCommand('This is the feed body', 'postername', 'http://image/sampleimage.jpg');
$response = $createFeedCommand->handle();
$this->assertInstanceOf('App\\Feed', $response);
}
开发者ID:aku345,项目名称:Larasocial,代码行数:8,代码来源:TestCreateFeedCommand.php
示例20: testAddNewFriendRequest
public function testAddNewFriendRequest()
{
$currentUser = Factory::create('App\\User');
$otherUser = Factory::create('App\\User');
Auth::login($currentUser);
$this->visit('users')->click('Add friend');
$this->assertResponseOk();
}
开发者ID:talha08,项目名称:Larasocial,代码行数:8,代码来源:FriendRequestTest.php
注:本文中的Laracasts\TestDummy\Factory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论