Example #1
0
 /**
  * @param $input
  * @param $expected
  * @dataProvider inputProvider
  */
 public function testWrite($input, $expected)
 {
     $pdo = $this->createPDO();
     $pdoStatement = $this->createPDOStatement();
     $connection = $this->createConnection($pdo);
     $statement = 'some sql statement';
     $returnInfo = 3;
     $pdo->expects($this->once())->method('prepare')->with($this->equalTo($statement))->will($this->returnValue($pdoStatement));
     $statementCount = 0;
     foreach ($input as $field => $value) {
         $pdoStatement->expects($this->at($statementCount++))->method('bindValue')->with($this->equalTo(":{$field}"), $this->equalTo($value), $this->equalTo($expected[$field]));
     }
     $pdoStatement->expects($this->once())->method('execute');
     $pdoStatement->expects($this->once())->method('rowCount')->will($this->returnValue($returnInfo));
     $query = new Query($connection);
     $this->assertEquals($returnInfo, $query->write($statement, $input));
 }
Example #2
0
 /**
  * Write a file
  *
  * @access public
  *
  * @param $path file path
  * @param $fh file descriptor
  * @param $offset offset to write from
  * @param $buf buffer to write */
 function write($path, $fh, $offset, $buf)
 {
     $bufLen = strlen($buf);
     Log::in("WRITE");
     Log::output("Path {$path}");
     Log::output("FH {$fh}");
     Log::output("Offset {$offset}");
     Log::output("Buffer size {$buflen}");
     /* Check for passthru */
     if (PassThru::check($path)) {
         $ret = PassThru::write($path, $offset, $bufLen, $buf);
     } else {
         $pi = Query::pathInfo($path);
         /* Get the content id from the path, or fh */
         Log::output("WRITE - filling content id");
         $ret = Query::fillContentId($pi, $fh);
         if ($ret != 0) {
             Log::out("WRITE - fill content - failed");
             return $ret;
         }
         Log::output("WRITE - calling query");
         $ret = Query::write($pi, $buf, $bufLen, $offset);
     }
     Log::out("WRITE");
     return $ret;
 }