diff options
author | Thomas Citharel <tcit@tcit.fr> | 2022-07-06 09:53:59 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-07-25 09:45:47 +0200 |
commit | 1d30fb7852e61cf9a2fcd03e83fa193c6aa5c827 (patch) | |
tree | 16fa15a59555ece94d1da53d160611fe28fbea8d /tests/lib | |
parent | 35a6f54bcd559016f4244ab0c38c2dd8a82c57cb (diff) | |
download | nextcloud-server-1d30fb7852e61cf9a2fcd03e83fa193c6aa5c827.tar.gz nextcloud-server-1d30fb7852e61cf9a2fcd03e83fa193c6aa5c827.zip |
Fix reading blob data as resource
PostgreSQL returns data as resource when using IQueryBuilder::PARAM_LOB
(which is used for QBMapper).
Previously we just converted this resource using settype, which produced
things like "Resource id #14" instead of the actual resource data.
Now we read the stream correctly if the returned data is a resource
See context at #22472
Fixes #22439
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/AppFramework/Db/EntityTest.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php index 17234849a2d..d76a8ccfe06 100644 --- a/tests/lib/AppFramework/Db/EntityTest.php +++ b/tests/lib/AppFramework/Db/EntityTest.php @@ -43,6 +43,8 @@ use PHPUnit\Framework\Constraint\IsType; * @method bool getAnotherBool() * @method bool isAnotherBool() * @method void setAnotherBool(bool $anotherBool) + * @method string getLongText() + * @method void setLongText(string $longText) */ class TestEntity extends Entity { protected $name; @@ -51,11 +53,13 @@ class TestEntity extends Entity { protected $preName; protected $trueOrFalse; protected $anotherBool; + protected $longText; public function __construct($name = null) { $this->addType('testId', 'integer'); $this->addType('trueOrFalse', 'bool'); $this->addType('anotherBool', 'boolean'); + $this->addType('longText', 'blob'); $this->name = $name; } } @@ -210,6 +214,18 @@ class EntityTest extends \Test\TestCase { $this->assertSame(null, $entity->getId()); } + public function testSetterConvertsResourcesToStringProperly() { + $string = 'Definitely a string'; + $stream = fopen('php://memory', 'r+'); + fwrite($stream, $string); + rewind($stream); + + $entity = new TestEntity(); + $entity->setLongText($stream); + fclose($stream); + $this->assertSame($string, $entity->getLongText()); + } + public function testGetFieldTypes() { $entity = new TestEntity(); @@ -218,6 +234,7 @@ class EntityTest extends \Test\TestCase { 'testId' => 'integer', 'trueOrFalse' => 'bool', 'anotherBool' => 'boolean', + 'longText' => 'blob', ], $entity->getFieldTypes()); } |