/** * Run the database seeds. * * @return void */ public function run() { $dbIndustryRepository = new DbIndustryRepository(); $dbCountryRepository = new DbCountryRepository(); $dbUserRepository = new DbUserRepository(); $healthIndustry = $dbIndustryRepository->findByName('Health'); $countries = $dbCountryRepository->all()->toArray(); $companyRepresentativeUsers = $dbUserRepository->withCompanyRepresentativeRole()->get()->toArray(); $faker = Factory::create(); foreach ($this->popularCompanies as $company) { factory(Company::class, 'relationless')->create(['name' => $company['name'], 'description' => $company['description'], 'industry_id' => $healthIndustry->id, 'country_id' => $faker->randomElement($countries)['id'], 'user_id' => $faker->randomElement($companyRepresentativeUsers)['id'], 'logo_id' => factory(File::class)->create()->id]); } }
/** @test */ public function it_finds_industry_by_name() { $dbIndustryRepository = new DbIndustryRepository(); $actualIndustry = factory(Industry::class)->create(); $keys = $actualIndustry->getFillable(); $expectedIndustry = $dbIndustryRepository->findByName($actualIndustry->name); $this->assertNotNull($expectedIndustry); $this->assertEquals(array_only($actualIndustry->toArray(), $keys), array_only($expectedIndustry->toArray(), $keys)); }
/** * Run the database seeds. * * @return void */ public function run() { $dbIndustryRepository = new DbIndustryRepository(); $healthIndustry = $dbIndustryRepository->findByName('Health'); factory(Article::class, 'without_industry', 3)->create(['industry_id' => $healthIndustry->id, 'publish' => 1]); }