當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。