public function testRequiredFields() { $loader = new BetterBulkLoader("BulkLoaderTest_Person"); $data = array(array("FirstName" => "joe", "Surname" => "Bloggs"), array("FirstName" => 0, "Surname" => "Bloggs"), array("FirstName" => null), array("FirstName" => "", "Surname" => ""), array("age" => "25", "Surname" => "Smith"), array("FirstName" => "Jane")); $loader->setSource(new ArrayBulkLoaderSource($data)); $loader->transforms = array('FirstName' => array('required' => true)); $results = $loader->load(); $this->assertEquals(2, $results->CreatedCount(), "Created 2"); $this->assertEquals(4, $results->SkippedCount(), "Skipped 4"); }
protected function processAll($filepath, $preview = false) { //configre a CsvBulkLoaderSource $source = new CsvBulkLoaderSource(); $source->setFilePath($filepath); $source->setHasHeader($this->hasHeaderRow); $source->setFieldDelimiter($this->delimiter); $source->setFieldEnclosure($this->enclosure); $this->setSource($source); return parent::processAll($filepath, $preview); }
public function __construct(DataList $list) { $this->list = $list; //TODO: user error if list is null parent::__construct($this->list->dataClass()); }