Пример #1
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage value is invalid: array
  */
 public function testInvalidLine()
 {
     $interpreter = new Interpreter();
     $table = 'test';
     $options = array('user' => $this->manager->getUser(), 'password' => $this->manager->getPassword());
     $sqlObserver = new PdoObserver($table, array('id', 'name'), $this->manager->getDsn(), $options);
     $interpreter->addObserver(array($sqlObserver, 'notify'));
     $interpreter->interpret(array('123', array('test', 'test')));
 }
Пример #2
0
 public function testUsageWithCallbackCollection()
 {
     $pdo = $this->manager->getPdo();
     $stmt = $pdo->prepare("SELECT * FROM collection_test");
     $stmt->execute();
     $pdoCollection = new PdoCollection($stmt);
     $callbackCollection = new CallbackCollection($pdoCollection, function ($row) {
         $row['test'] = 'test';
         return $row;
     });
     foreach ($callbackCollection as $line) {
         $this->assertEquals('test', $line['test']);
     }
 }
Пример #3
0
 public function testUsage()
 {
     $pdo = $this->manager->getPdo();
     $stmt = $pdo->prepare("SELECT * FROM collection_test");
     $stmt->execute();
     $this->assertFileNotExists('vfs://output/data.csv');
     $collection = new PdoCollection($stmt);
     $config = new ExporterConfig();
     $exporter = new Exporter($config);
     $exporter->export('vfs://output/data.csv', $collection);
     $expectedContents = "1,name\r\n";
     $expectedContents .= "2,name\r\n";
     $expectedContents .= "3,name\r\n";
     $this->assertSame($expectedContents, file_get_contents('vfs://output/data.csv'));
 }