public function testGetQuery() { $result = $this->getMock('r8\\iface\\DB\\Result\\Read'); $result->expects($this->once())->method('getQuery')->will($this->returnValue("SELECT 1 + 1")); $dec = $this->getTestDecorator($result); \r8\Test\Constraint\SQL::assert("SELECT 1 + 1", $result->getQuery()); }
public function testQuery_write() { $link = $this->getTestLink(); $result = $link->query("CREATE TEMPORARY TABLE `" . MYSQLI_TABLE . "` (\n `id` INT NOT NULL auto_increment,\n PRIMARY KEY ( `id` )\n )"); $this->assertThat($result, $this->isInstanceOf('\\r8\\DB\\Result\\Write')); $this->assertSame(0, $result->getAffected()); $this->assertNull($result->getInsertID()); $result = $link->query("INSERT INTO " . MYSQLI_TABLE . " SET id = NULL"); $this->assertThat($result, $this->isInstanceOf('\\r8\\DB\\Result\\Write')); $this->assertSame(1, $result->getAffected()); $this->assertSame(1, $result->getInsertID()); \r8\Test\Constraint\SQL::assert("INSERT INTO " . MYSQLI_TABLE . " SET id = NULL", $result->getQuery()); }
public function testQuery_write() { $link = $this->getTestLink(); $result = $link->query("CREATE TEMPORARY TABLE " . SQLITE_TABLE . "(id INT, str TEXT)"); $this->assertThat($result, $this->isInstanceOf('\\r8\\DB\\Result\\Write')); $this->assertSame(0, $result->getAffected()); $this->assertNull($result->getInsertID()); $result = $link->query("INSERT INTO " . SQLITE_TABLE . " (str) VALUES ('alpha')"); $this->assertThat($result, $this->isInstanceOf('\\r8\\DB\\Result\\Write')); $this->assertSame(1, $result->getAffected()); $this->assertSame(1, $result->getInsertID()); \r8\Test\Constraint\SQL::assert("INSERT INTO " . SQLITE_TABLE . " (str) VALUES ('alpha')", $result->getQuery()); }