Skip to content

Commit

Permalink
Actually test that BLOBS are correctly written (Request #10805).
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Feb 3, 2017
1 parent f94c458 commit 8867906
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions framework/Db/test/Horde/Db/Adapter/TestBase.php
Expand Up @@ -204,6 +204,7 @@ public function testInsert()
public function testInsertBlob()
{
$this->_createTable();
$columns = $this->_conn->columns('unit_tests');

$result = $this->_conn->insertBlob(
'unit_tests',
Expand All @@ -216,6 +217,12 @@ public function testInsertBlob()
7
);
$this->assertEquals(7, $result);
$this->assertEquals(
str_repeat("\0", 5000),
$columns['blob_value']->binaryToString($this->_conn->selectValue(
'SELECT blob_value FROM unit_tests WHERE id = 7'
))
);

$result = $this->_conn->insertBlob(
'unit_tests',
Expand All @@ -228,10 +235,15 @@ public function testInsertBlob()
8
);
$this->assertEquals(8, $result);
$this->assertEquals(
str_repeat('X', 5000),
$columns['text_value']->binaryToString($this->_conn->selectValue(
'SELECT text_value FROM unit_tests WHERE id = 8'
))
);

$stream = fopen('php://temp', 'r+');
fwrite($stream, str_repeat('X', 5000));
rewind($stream);
$result = $this->_conn->insertBlob(
'unit_tests',
array(
Expand All @@ -243,9 +255,14 @@ public function testInsertBlob()
9
);
$this->assertEquals(9, $result);
$this->assertEquals(
str_repeat('X', 5000),
$columns['text_value']->binaryToString($this->_conn->selectValue(
'SELECT text_value FROM unit_tests WHERE id = 9'
))
);

$stream = fopen('php://temp', 'r+');
rewind($stream);
fwrite($stream, str_repeat("\0", 10000));
$result = $this->_conn->insertBlob(
'unit_tests',
Expand All @@ -258,6 +275,12 @@ public function testInsertBlob()
10
);
$this->assertEquals(10, $result);
$this->assertEquals(
str_repeat("\0", 10000),
$columns['blob_value']->binaryToString($this->_conn->selectValue(
'SELECT blob_value FROM unit_tests WHERE id = 10'
))
);
}


Expand Down Expand Up @@ -295,7 +318,6 @@ public function testUpdateBlob()

$stream = fopen('php://temp', 'r+');
fwrite($stream, str_repeat('X', 5001));
rewind($stream);
$result = $this->_conn->updateBlob(
'unit_tests',
array(
Expand All @@ -307,7 +329,6 @@ public function testUpdateBlob()

$stream = fopen('php://temp', 'r+');
fwrite($stream, str_repeat("\0", 5001));
rewind($stream);
$result = $this->_conn->updateBlob(
'unit_tests',
array(
Expand Down

0 comments on commit 8867906

Please sign in to comment.