sql($this->testQuery); $this->assertSame($this->testQuery . ';', '' . $sql); } public function testToStringShouldNotAppendSemicolonIfNotNeeded() { $sql = $this->sql($this->testQuery . ';'); $this->assertSame($this->testQuery . ';', '' . $sql); } public function testToStringShouldNotAppendSemicolonIfNoQueryGiven() { $sql = $this->sql(''); $this->assertSame('', '' . $sql); } public function testExecShouldNotFailWhenNoQueryGiven() { $sql = $this->sql(''); $this->assertNull($sql->exec()); } public function testConstructorShouldConvertErrorCodeToArrayIfNeeded() { $sql = $this->sql($this->testQuery, 1091); $this->assertSame(array(1091), $sql->getErrorCodesToIgnore()); } public function testConstructorShouldNotConvertErrorCodeToArrayIfNotNeeded() { $sql = $this->sql($this->testQuery, array(1091, 1061)); $this->assertSame(array(1091, 1061), $sql->getErrorCodesToIgnore()); } public function testAddErrorCodeToIgnoreAddsOneErrorCode() { $sql = $this->sql($this->testQuery, array(1091, 1061)); $sql->addErrorCodeToIgnore(1049); $this->assertSame(array(1091, 1061, 1049), $sql->getErrorCodesToIgnore()); } private function sql($query, $errorCode = false) { return new Sql($query, $errorCode); } }