Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2022-07-25 18:56:03 +0300
committerGitHub <noreply@github.com>2022-07-25 18:56:03 +0300
commitbbe15b4b43f95e1600f5122a7bf72a64ee404b36 (patch)
treea0c5d10465ac3ebf13b31bd8e91f0274ef1f6591 /tests
parentc523fd1ed76393d79367a598cd89a345f525ea23 (diff)
parent1d30fb7852e61cf9a2fcd03e83fa193c6aa5c827 (diff)
Merge pull request #33129 from nextcloud/fix-reading-blob-as-resources
Fix reading blob data as resource
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/AppFramework/Db/EntityTest.php17
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());
}