public function testLoadWithCustomImportMethodDuplicateMap() { $loader = new CsvBulkLoaderTest_CustomLoader('CsvBulkLoaderTest_Player'); $filepath = $this->getCurrentAbsolutePath() . '/CsvBulkLoaderTest_PlayersWithHeader.csv'; $loader->columnMap = array('FirstName' => '->updatePlayer', 'Biography' => '->updatePlayer', 'Birthday' => 'Birthday', 'IsRegistered' => 'IsRegistered'); $results = $loader->load($filepath); $createdPlayers = $results->Created(); $player = $createdPlayers->First(); $this->assertEquals($player->FirstName, "John. He's a good guy. "); }
function testLoadWithCustomImportMethods() { $loader = new CsvBulkLoaderTest_CustomLoader('CsvBulkLoaderTest_Player'); $filepath = Director::baseFolder() . '/sapphire/tests/dev/CsvBulkLoaderTest_PlayersWithHeader.csv'; $loader->columnMap = array('FirstName' => '->importFirstName', 'Biography' => 'Biography', 'Birthday' => 'Birthday', 'IsRegistered' => 'IsRegistered'); $results = $loader->load($filepath); $createdPlayers = $results->Created(); $player = $createdPlayers->First(); $this->assertEquals($player->FirstName, 'Customized John'); $this->assertEquals($player->Biography, "He's a good guy"); $this->assertEquals($player->IsRegistered, "1"); }