diff options
Diffstat (limited to 'tests/lib/DB/LegacyDBTest.php')
-rw-r--r-- | tests/lib/DB/LegacyDBTest.php | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/tests/lib/DB/LegacyDBTest.php b/tests/lib/DB/LegacyDBTest.php index ce7ef0a3a63..cd4befdbe52 100644 --- a/tests/lib/DB/LegacyDBTest.php +++ b/tests/lib/DB/LegacyDBTest.php @@ -85,15 +85,15 @@ class LegacyDBTest extends \Test\TestCase { public function testQuotes() { $query = OC_DB::prepare('SELECT `fullname` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(array('uri_1')); + $result = $query->execute(['uri_1']); $this->assertTrue((bool)$result); $row = $result->fetchRow(); $this->assertFalse($row); $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)'); - $result = $query->execute(array('fullname test', 'uri_1')); + $result = $query->execute(['fullname test', 'uri_1']); $this->assertEquals(1, $result); $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(array('uri_1')); + $result = $query->execute(['uri_1']); $this->assertTrue((bool)$result); $row = $result->fetchRow(); $this->assertArrayHasKey('fullname', $row); @@ -107,29 +107,29 @@ class LegacyDBTest extends \Test\TestCase { */ public function testNOW() { $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (NOW(),?)'); - $result = $query->execute(array('uri_2')); + $result = $query->execute(['uri_2']); $this->assertEquals(1, $result); $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(array('uri_2')); + $result = $query->execute(['uri_2']); $this->assertTrue((bool)$result); } public function testUNIX_TIMESTAMP() { $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (UNIX_TIMESTAMP(),?)'); - $result = $query->execute(array('uri_3')); + $result = $query->execute(['uri_3']); $this->assertEquals(1, $result); $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(array('uri_3')); + $result = $query->execute(['uri_3']); $this->assertTrue((bool)$result); } public function testLastInsertId() { $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)'); - $result1 = OC_DB::executeAudited($query, array('insertid 1','uri_1')); + $result1 = OC_DB::executeAudited($query, ['insertid 1','uri_1']); $id1 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2); // we don't know the id we should expect, so insert another row - $result2 = OC_DB::executeAudited($query, array('insertid 2','uri_2')); + $result2 = OC_DB::executeAudited($query, ['insertid 2','uri_2']); $id2 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2); // now we can check if the two ids are in correct order $this->assertGreaterThan($id1, $id2); @@ -140,7 +140,7 @@ class LegacyDBTest extends \Test\TestCase { $expected = "ะรถ้ๅ\xE2\x80\xA2"; $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $result = $query->execute(array($expected, 'uri_1', 'This is a vCard')); + $result = $query->execute([$expected, 'uri_1', 'This is a vCard']); $this->assertEquals(1, $result); $actual = OC_DB::prepare("SELECT `fullname` FROM `$table`")->execute()->fetchOne(); @@ -156,7 +156,7 @@ class LegacyDBTest extends \Test\TestCase { $rowname = 'decimaltest'; $query = OC_DB::prepare('INSERT INTO `' . $table . '` (`' . $rowname . '`) VALUES (?)'); - $result = $query->execute(array($insert)); + $result = $query->execute([$insert]); $this->assertEquals(1, $result); $query = OC_DB::prepare('SELECT `' . $rowname . '` FROM `' . $table . '`'); $result = $query->execute(); @@ -205,35 +205,35 @@ class LegacyDBTest extends \Test\TestCase { // updating to. MySQL reports 1 here when the PDO::MYSQL_ATTR_FOUND_ROWS // flag is not specified. $query = OC_DB::prepare("UPDATE `*PREFIX*{$this->table2}` SET `uri` = ?"); - $this->assertSame(2, $query->execute(array('uri1'))); + $this->assertSame(2, $query->execute(['uri1'])); } protected function insertCardData($fullname, $uri) { $query = OC_DB::prepare("INSERT INTO `*PREFIX*{$this->table2}` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $this->assertSame(1, $query->execute(array($fullname, $uri, $this->getUniqueID()))); + $this->assertSame(1, $query->execute([$fullname, $uri, $this->getUniqueID()])); } protected function updateCardData($fullname, $uri) { $query = OC_DB::prepare("UPDATE `*PREFIX*{$this->table2}` SET `uri` = ? WHERE `fullname` = ?"); - return $query->execute(array($uri, $fullname)); + return $query->execute([$uri, $fullname]); } public function testILIKE() { $table = "*PREFIX*{$this->table2}"; $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $query->execute(array('fooBAR', 'foo', 'bar')); + $query->execute(['fooBAR', 'foo', 'bar']); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(array('foobar')); + $result = $query->execute(['foobar']); $this->assertCount(0, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(array('foobar')); + $result = $query->execute(['foobar']); $this->assertCount(1, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(array('foo')); + $result = $query->execute(['foo']); $this->assertCount(0, $result->fetchAll()); } @@ -241,30 +241,30 @@ class LegacyDBTest extends \Test\TestCase { $table = "*PREFIX*{$this->table2}"; $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $query->execute(array('FooBAR', 'foo', 'bar')); + $query->execute(['FooBAR', 'foo', 'bar']); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(array('%bar')); + $result = $query->execute(['%bar']); $this->assertCount(0, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(array('foo%')); + $result = $query->execute(['foo%']); $this->assertCount(0, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(array('%ba%')); + $result = $query->execute(['%ba%']); $this->assertCount(0, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(array('%bar')); + $result = $query->execute(['%bar']); $this->assertCount(1, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(array('foo%')); + $result = $query->execute(['foo%']); $this->assertCount(1, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(array('%ba%')); + $result = $query->execute(['%ba%']); $this->assertCount(1, $result->fetchAll()); } @@ -279,7 +279,7 @@ class LegacyDBTest extends \Test\TestCase { if ($throwsOnMysqlWithoutUTF8MB4 && $config->getSystemValue('dbtype', 'sqlite') === 'mysql' && $config->getSystemValue('mysql.utf8mb4', false) === false) { $this->markTestSkipped('MySQL requires UTF8mb4 to store value: ' . $expected); } - $result = $query->execute(array($expected)); + $result = $query->execute([$expected]); $this->assertEquals(1, $result); $actual = OC_DB::prepare("SELECT `textfield` FROM `$table`")->execute()->fetchOne(); |