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/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Comments/ManagerTest.php14
-rw-r--r--tests/lib/DB/QueryBuilder/FunctionBuilderTest.php50
2 files changed, 57 insertions, 7 deletions
diff --git a/tests/lib/Comments/ManagerTest.php b/tests/lib/Comments/ManagerTest.php
index 23a9346909a..961f8dfdd41 100644
--- a/tests/lib/Comments/ManagerTest.php
+++ b/tests/lib/Comments/ManagerTest.php
@@ -3,6 +3,7 @@
namespace Test\Comments;
use OC\Comments\Comment;
+use OC\Comments\EmojiHelper;
use OC\Comments\Manager;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Comments\IComment;
@@ -74,6 +75,7 @@ class ManagerTest extends TestCase {
$this->createMock(LoggerInterface::class),
$this->createMock(IConfig::class),
$this->createMock(ITimeFactory::class),
+ new EmojiHelper($this->connection),
$this->createMock(IInitialStateService::class)
);
}
@@ -1181,15 +1183,13 @@ class ManagerTest extends TestCase {
public function providerTestReactionMessageSize(): array {
return [
- ['a', true],
- ['1', true],
- ['12', true],
- ['123', false],
+ ['a', false],
+ ['1', false],
['πŸ‘', true],
- ['πŸ‘πŸ‘', true],
+ ['πŸ‘πŸ‘', false],
['πŸ‘πŸ½', true],
- ['πŸ‘πŸ½πŸ‘', false],
- ['πŸ‘πŸ½πŸ‘πŸ½', false],
+ ['πŸ‘¨πŸ½β€πŸ’»', true],
+ ['πŸ‘¨πŸ½β€πŸ’»πŸ‘', false],
];
}
diff --git a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
index 3f4b8bb7524..08392b09d8d 100644
--- a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
@@ -336,6 +336,56 @@ class FunctionBuilderTest extends TestCase {
$this->assertGreaterThan(1, $column);
}
+ public function octetLengthProvider() {
+ return [
+ ['', 0],
+ ['foobar', 6],
+ ['fΓ©', 3],
+ ['őđčćž', 10],
+ ];
+ }
+
+ /**
+ * @dataProvider octetLengthProvider
+ */
+ public function testOctetLength(string $str, int $bytes) {
+ $query = $this->connection->getQueryBuilder();
+
+ $query->select($query->func()->octetLength($query->createNamedParameter($str, IQueryBuilder::PARAM_STR)));
+ $query->from('appconfig')
+ ->setMaxResults(1);
+
+ $result = $query->execute();
+ $column = $result->fetchOne();
+ $result->closeCursor();
+ $this->assertEquals($bytes, $column);
+ }
+
+ public function charLengthProvider() {
+ return [
+ ['', 0],
+ ['foobar', 6],
+ ['fΓ©', 2],
+ ['őđčćž', 5],
+ ];
+ }
+
+ /**
+ * @dataProvider charLengthProvider
+ */
+ public function testCharLength(string $str, int $bytes) {
+ $query = $this->connection->getQueryBuilder();
+
+ $query->select($query->func()->charLength($query->createNamedParameter($str, IQueryBuilder::PARAM_STR)));
+ $query->from('appconfig')
+ ->setMaxResults(1);
+
+ $result = $query->execute();
+ $column = $result->fetchOne();
+ $result->closeCursor();
+ $this->assertEquals($bytes, $column);
+ }
+
private function setUpMinMax($value) {
$query = $this->connection->getQueryBuilder();