mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
4 files changed
+86
-59
No files matched your search
@@ -1,28 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Utopia\Mongo\Adapter;
|
||||
|
||||
use Utopia\Mongo\Adapter;
|
||||
|
||||
class SwooleClient extends Adapter
|
||||
{
|
||||
public function isConnected(): bool
|
||||
{
|
||||
// TODO: Implement isConnected() method.
|
||||
}
|
||||
|
||||
public function connect(string $host, int $port = null, float $timeout = null): bool
|
||||
{
|
||||
// TODO: Implement connect() method.
|
||||
}
|
||||
|
||||
public function send(mixed $data): int|bool
|
||||
{
|
||||
// TODO: Implement send() method.
|
||||
}
|
||||
|
||||
public function recv(int $timeout = null): string|bool
|
||||
{
|
||||
// TODO: Implement recv() method.
|
||||
}
|
||||
}
|
||||
//
|
||||
//namespace Utopia\Mongo\Adapter;
|
||||
//
|
||||
//use Utopia\Mongo\Adapter;
|
||||
//
|
||||
//class SwooleClient extends Adapter
|
||||
//{
|
||||
// public function isConnected(): bool
|
||||
// {
|
||||
// // TODO: Implement isConnected() method.
|
||||
// }
|
||||
//
|
||||
// public function connect(string $host, int $port = null, float $timeout = null): bool
|
||||
// {
|
||||
// // TODO: Implement connect() method.
|
||||
// }
|
||||
//
|
||||
// public function send(mixed $data): int|bool
|
||||
// {
|
||||
// // TODO: Implement send() method.
|
||||
// }
|
||||
//
|
||||
// public function recv(int $timeout = null): string|bool
|
||||
// {
|
||||
// // TODO: Implement recv() method.
|
||||
// }
|
||||
//}
|
||||
@@ -1,28 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Utopia\Mongo\Adapter;
|
||||
|
||||
use Utopia\Mongo\Adapter;
|
||||
|
||||
class SwooleCoroutineClient extends Adapter
|
||||
{
|
||||
public function isConnected(): bool
|
||||
{
|
||||
// TODO: Implement isConnected() method.
|
||||
}
|
||||
|
||||
public function connect(string $host, int $port = null, float $timeout = null): bool
|
||||
{
|
||||
// TODO: Implement connect() method.
|
||||
}
|
||||
|
||||
public function send(mixed $data): int|bool
|
||||
{
|
||||
// TODO: Implement send() method.
|
||||
}
|
||||
|
||||
public function recv(int $timeout = null): string|bool
|
||||
{
|
||||
// TODO: Implement recv() method.
|
||||
}
|
||||
}
|
||||
//
|
||||
//namespace Utopia\Mongo\Adapter;
|
||||
//
|
||||
//use Utopia\Mongo\Adapter;
|
||||
//
|
||||
//class SwooleCoroutineClient extends Adapter
|
||||
//{
|
||||
// public function isConnected(): bool
|
||||
// {
|
||||
// // TODO: Implement isConnected() method.
|
||||
// }
|
||||
//
|
||||
// public function connect(string $host, int $port = null, float $timeout = null): bool
|
||||
// {
|
||||
// // TODO: Implement connect() method.
|
||||
// }
|
||||
//
|
||||
// public function send(mixed $data): int|bool
|
||||
// {
|
||||
// // TODO: Implement send() method.
|
||||
// }
|
||||
//
|
||||
// public function recv(int $timeout = null): string|bool
|
||||
// {
|
||||
// // TODO: Implement recv() method.
|
||||
// }
|
||||
//}
|
||||
+9
-6
@@ -202,14 +202,21 @@ class Client
|
||||
$result = BSON\toPHP(substr($res, 21, $responseLength - 21));
|
||||
|
||||
if (property_exists($result, "writeErrors")) {
|
||||
// Throws a Utopia\Mongo\Exception with Code Error
|
||||
|
||||
// Throws Utopia\Mongo\Exception
|
||||
throw new Exception(
|
||||
$result->writeErrors[0]->errmsg,
|
||||
$result->writeErrors[0]->code
|
||||
);
|
||||
}
|
||||
|
||||
if (property_exists($result, 'errmsg')) {
|
||||
// Throws Utopia\Mongo\Exception
|
||||
throw new Exception(
|
||||
'E'.$result->code.' '.$result->codeName.': '.$result->errmsg,
|
||||
$result->code
|
||||
);
|
||||
}
|
||||
|
||||
if (property_exists($result, "n") && $result->ok === 1.0) {
|
||||
return $result->n;
|
||||
}
|
||||
@@ -218,10 +225,6 @@ class Client
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (property_exists($result, 'errmsg')) {
|
||||
throw new Exception($result->errmsg);
|
||||
}
|
||||
|
||||
if ($result->ok === 1.0) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
+23
-1
@@ -106,9 +106,31 @@ class MongoTest extends TestCase
|
||||
self::assertIsArray($doc->array);
|
||||
self::assertIsString($doc->date_string);
|
||||
self::assertIsObject($doc->date_object); // Todo: This is not working can't retrieve the object back
|
||||
}
|
||||
|
||||
public function testDriverException()
|
||||
{
|
||||
self::expectException('MongoDB\Driver\Exception\InvalidArgumentException');
|
||||
self::expectExceptionCode(0);
|
||||
new ObjectId('triggerAnError');
|
||||
}
|
||||
|
||||
public function testDuplicationException()
|
||||
{
|
||||
self::expectException(Exception::class);
|
||||
self::expectExceptionCode(11000);
|
||||
$this->getDatabase()->insert('movies', ['_id' => 999, 'b' => 'Duplication']);
|
||||
$this->getDatabase()->insert('movies', ['_id' => 999]);
|
||||
}
|
||||
|
||||
public function testExceedTimeException()
|
||||
{
|
||||
self::expectException(Exception::class);
|
||||
self::expectExceptionCode(50);
|
||||
|
||||
$this->getDatabase()->find(
|
||||
'movies',
|
||||
['$where' => 'sleep(1000) || true'],
|
||||
['maxTimeMS'=> 1]
|
||||
)->cursor->firstBatch ?? [];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user