/** * @test */ public function it_should_have_a_name_and_company() { $company = Company::createWithoutServices(new CompanyName('FooBar')); $service = Service::offer(new ProvidedService('Hammers for Rental'), $company); $this->assertSame($company, $service->getCompany()); $this->assertEquals(new ProvidedService('Hammers for Rental'), $service->getProvidedService()); }
/** * {@inheritdoc} */ function load(ObjectManager $manager) { $company = Company::createWithoutServices(new CompanyName('Virgin Media')); $this->setReference('company_vm', $company); $manager->persist($company); $manager->flush(); }
/** * @test */ public function it_should_be_able_to_offer_services_after_instantiation() { $company = Company::createWithoutServices(new CompanyName('Acme')); $this->assertEquals(new \Doctrine\Common\Collections\ArrayCollection(), $company->getOfferedServices()); $service = Service::offer(new ProvidedService('Hammers for Renting'), $company); $company->offerService($service); $services = new \Doctrine\Common\Collections\ArrayCollection([$service]); $this->assertEquals($services, $company->getOfferedServices()); }
/** * @return Service */ private function createServicesAndCompany() { $company = Company::createWithoutServices(new Value\CompanyName('Acme')); return Service::offer(new Value\ProvidedService('Hammers for Rental'), $company); }
/** * @param CreateCompanyCommand $command * @return void */ public function handle($command) { $company = Company::createWithoutServices($command->getCompanyName()); $this->companyRepository->save($company); }