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


PHP Factory::build方法代码示例

本文整理汇总了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;
 }
开发者ID:timegridio,项目名称:concierge,代码行数:7,代码来源:CreateDomain.php

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

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

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

示例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;
 }
开发者ID:timegridio,项目名称:concierge,代码行数:7,代码来源:CreateUser.php

示例6: makeContact

 private function makeContact(User $user = null, $overrides = [])
 {
     $contact = Factory::build(Contact::class, $overrides);
     if ($user) {
         $contact->user()->associate($user);
     }
     return $contact;
 }
开发者ID:timegridio,项目名称:concierge,代码行数:8,代码来源:CreateContact.php

示例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;
 }
开发者ID:timegridio,项目名称:concierge,代码行数:8,代码来源:CreateAppointment.php

示例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]);
 }
开发者ID:billwaddyjr,项目名称:Larabook2.0,代码行数:11,代码来源:StatusRepositoryTest.php

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

示例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);
     });
 }
开发者ID:npmweb,项目名称:service-opportunities,代码行数:13,代码来源:CampaignTest.php

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

示例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);
 }
开发者ID:Rotron,项目名称:laravel5-shop,代码行数:6,代码来源:FactoryTest.php

示例13: setUp

 public function setUp()
 {
     parent::setUp();
     $this->model = Factory::build(Attribute::class);
 }
开发者ID:npmweb,项目名称:service-opportunities,代码行数:5,代码来源:AttributeTest.php

示例14: setUp

 public function setUp()
 {
     parent::setUp();
     $this->model = Factory::build(OpportunityOccurrence::class);
 }
开发者ID:npmweb,项目名称:service-opportunities,代码行数:5,代码来源:OpportunityOccurrenceTest.php

示例15: makeService

 private function makeService($overrides = [])
 {
     return Factory::build(Service::class, $overrides);
 }
开发者ID:timegridio,项目名称:concierge,代码行数:4,代码来源:CreateService.php


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