importResource() public method

array fgetcsv ( resource $handle [, int $length = 0 [, string $delimiter = "," [, string $enclosure = '"' [, string $escape = "\" ]]]] ).
public importResource ( $fd, $unsetPrimaryKey = false )
Ejemplo n.º 1
0
 public function testCollectionExporter()
 {
     $author = new Author();
     foreach (range(1, 10) as $i) {
         $ret = $author->create(array('name' => 'Foo-' . $i, 'email' => 'foo@foo' . $i, 'identity' => 'foo' . $i, 'confirmed' => true));
         $this->assertTrue($author->confirmed, 'is true');
         $this->assertTrue($ret->success);
     }
     @mkdir('tests/tmp', 0755, true);
     $fp = fopen('tests/tmp/authors.csv', 'w');
     $exporter = new CSVExporter($fp);
     $exporter->exportCollection(new AuthorCollection());
     fclose($fp);
     $authors = new AuthorCollection();
     $authors->delete();
     $fp = fopen('tests/tmp/authors.csv', 'r');
     $importer = new CSVImporter(new Author());
     $importer->importResource($fp);
     fclose($fp);
 }