public function testGetSetCountry() { $expected = Country::getCountryName('FOO'); $this->assertEmpty($this->instance->getCountry()); $this->assertInstanceOf(Authority::class, $this->instance->setCountry($expected)); $this->assertEquals($expected, $this->instance->getCountry()); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $file = $input->getArgument('path'); $counter = 0; $handle = $this->checkForAndOpenFile($file, $output); if (true === is_resource($handle)) { $authService = $this->getAuthorityService(); while ($row = fgetcsv($handle)) { if ($counter > 0) { $data = array_combine($this->headers, $row); $authority = new Authority(); $authority->setPostcode($data['pcd']); $authority = $this->addCountyToAuthority($data['oscty'], $authority); $authority = $this->addDistrictCouncilToAuthority($data['oslaua'], $authority); $authority->setCountry(Country::getCountryName($data['ctry'])); $authority = $this->addLocalHealthAuthorityToAuthority($data['pct'], $authority); $authority = $this->addElectoralWardToAuthority($data['osward'], $authority); $authority = $this->addParishCouncilToAuthority($data['parish'], $authority); $authority = $authService->saveAuthority($authority); $action = 'Created'; if (null !== $authority->getLastUpdated()) { $action = 'Updated'; } $output->writeln($action . ' Authority for ' . $authority->getPostcode() . ' with id ' . $authority->getId()); } else { $this->extractHeaders($row); } ++$counter; } fclose($handle); } }
public function testGetCountryNameDefaultsToUnknown() { $expected = 'Unknown'; $query = 'SOMEPLACE'; $this->assertEquals($expected, Country::getCountryName($query)); }