本文整理汇总了PHP中Laracasts\TestDummy\Factory::build方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::build方法的具体用法?PHP Factory::build怎么用?PHP Factory::build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laracasts\TestDummy\Factory
的用法示例。
在下文中一共展示了Factory::build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeDomain
private function makeDomain(User $owner, $overrides = [])
{
$domain = Factory::build(Domain::class, $overrides);
$domain->save();
$domain->owners()->attach($owner);
return $domain;
}
示例2: testStore
public function testStore()
{
$user = Factory::build('User');
$input = array_only($user->getAttributes(), $user->getFillable());
$this->action('POST', 'Admin\\UsersController@store', $input);
$this->assertRedirectedToRoute('admin.users.show', User::first()->id);
}
示例3: makeBusiness
private function makeBusiness(User $owner, $overrides = [])
{
$business = Factory::build(Business::class, $overrides);
$business->save();
$business->owners()->attach($owner);
return $business;
}
示例4: testStore
public function testStore()
{
$project = Factory::build('Project', ['name' => 'Foo']);
$input = array_only($project->getAttributes(), $project->getFillable());
$this->action('POST', 'Admin\\ProjectsController@store', $input);
$this->assertRedirectedToRoute('admin.projects.show', 'foo');
}
示例5: makeUser
private function makeUser($overrides = [])
{
# $user = factory(User::class)->make($overrides);
$user = Factory::build('Timegridio\\Tests\\Models\\User', $overrides);
$user->email = 'guest@example.org';
return $user;
}
示例6: makeContact
private function makeContact(User $user = null, $overrides = [])
{
$contact = Factory::build(Contact::class, $overrides);
if ($user) {
$contact->user()->associate($user);
}
return $contact;
}
示例7: makeAppointment
private function makeAppointment(Business $business, User $issuer, Contact $contact, $override = [])
{
$appointment = Factory::build(Appointment::class, $override);
$appointment->contact()->associate($contact);
$appointment->issuer()->associate($issuer);
$appointment->business()->associate($business);
return $appointment;
}
示例8: it_saves_a_status_for_a_user
/** @test */
public function it_saves_a_status_for_a_user()
{
// Given
$user = TestDummy::create('Larabook\\Users\\User');
$unsavedStatus = TestDummy::build('Larabook\\Statuses\\Status', ['body' => 'This is a test status', 'user_id' => null]);
// When
$this->repository->save($unsavedStatus, $user->id);
// Then
$this->tester->seeRecord('statuses', ['body' => 'This is a test status', 'user_id' => $user->id]);
}
示例9: it_saves_a_status_for_a_user
/** @test */
public function it_saves_a_status_for_a_user()
{
// Given I have an unsaved status
$status = TestDummy::build('Larabook\\Statuses\\Status', ['user_id' => null, 'body' => 'My status']);
// And an existing user
$user = TestDummy::create('Larabook\\Users\\User');
// When I try to persist this status
$this->repo->save($status, $user->id);
// Then it should be saved
$this->tester->seeRecord('statuses', ['body' => 'My status', 'user_id' => $user->id]);
}
示例10: function
function test_it_should_not_allow_special_characters_in_permalinks()
{
// arrange
$models = [Factory::build(Campaign::class, ['permalink' => 'foo!bar']), Factory::build(Campaign::class, ['permalink' => 'foo bar']), Factory::build(Campaign::class, ['permalink' => 'foo&bar']), Factory::build(Campaign::class, ['permalink' => 'foo\'bar'])];
// act
$results = array_map(function ($model) {
return $model->validate();
}, $models);
// assert
array_walk($results, function ($isValid) {
$this->assertFalse($isValid);
});
}
示例11: it_saves_a_status_for_a_specific_user
/** @test */
public function it_saves_a_status_for_a_specific_user()
{
// Given I have unsaved status
$status = Factory::build(Status::class, ['user_id' => null, 'body' => 'My Status']);
// And an existing user
$user = Factory::create(User::class);
// When I try to persist this status
$savedStatus = $this->repo->save($status, $user);
// Then it should be saved
$this->tester->seeRecord('statuses', ['body' => 'My Status']);
// And the status should have the correct user_id
$this->assertEquals($user->id, $savedStatus->user_id);
}
示例12: it_accepts_a_short_name_identifier_instead_of_the_model_class
/** @test */
public function it_accepts_a_short_name_identifier_instead_of_the_model_class()
{
$post = TestDummy::build('scheduled_post');
assertInstanceOf('Post', $post);
}
示例13: setUp
public function setUp()
{
parent::setUp();
$this->model = Factory::build(Attribute::class);
}
示例14: setUp
public function setUp()
{
parent::setUp();
$this->model = Factory::build(OpportunityOccurrence::class);
}
示例15: makeService
private function makeService($overrides = [])
{
return Factory::build(Service::class, $overrides);
}