diff --git a/.phpunit.cache/code-coverage/0bafe3ee548b26d1174d1f37ae5bcca8 b/.phpunit.cache/code-coverage/0bafe3ee548b26d1174d1f37ae5bcca8 new file mode 100644 index 0000000..090a056 --- /dev/null +++ b/.phpunit.cache/code-coverage/0bafe3ee548b26d1174d1f37ae5bcca8 @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:1:{s:52:"Maatify\DataAdapters\Adapters\MySQL\MySQLDBALAdapter";a:6:{s:4:"name";s:16:"MySQLDBALAdapter";s:14:"namespacedName";s:52:"Maatify\DataAdapters\Adapters\MySQL\MySQLDBALAdapter";s:9:"namespace";s:35:"Maatify\DataAdapters\Adapters\MySQL";s:9:"startLine";i:24;s:7:"endLine";i:35;s:7:"methods";a:2:{s:11:"__construct";a:6:{s:10:"methodName";s:11:"__construct";s:9:"signature";s:45:"__construct(Doctrine\DBAL\Connection $driver)";s:10:"visibility";s:6:"public";s:9:"startLine";i:26;s:7:"endLine";i:29;s:3:"ccn";i:1;}s:9:"getDriver";a:6:{s:10:"methodName";s:9:"getDriver";s:9:"signature";s:19:"getDriver(): object";s:10:"visibility";s:6:"public";s:9:"startLine";i:31;s:7:"endLine";i:34;s:3:"ccn";i:1;}}}}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:36;s:18:"commentLinesOfCode";i:13;s:21:"nonCommentLinesOfCode";i:23;}s:15:"ignoredLinesFor";a:1:{i:0;i:24;}s:17:"executableLinesIn";a:2:{i:29;i:1;i:33;i:2;}} \ No newline at end of file diff --git a/.phpunit.cache/code-coverage/6087a84e3a98f0bae2a7c442c2e355f0 b/.phpunit.cache/code-coverage/6087a84e3a98f0bae2a7c442c2e355f0 new file mode 100644 index 0000000..7a97438 --- /dev/null +++ b/.phpunit.cache/code-coverage/6087a84e3a98f0bae2a7c442c2e355f0 @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:1:{s:45:"Maatify\DataAdapters\TestDoubles\DummyAdapter";a:6:{s:4:"name";s:12:"DummyAdapter";s:14:"namespacedName";s:45:"Maatify\DataAdapters\TestDoubles\DummyAdapter";s:9:"namespace";s:32:"Maatify\DataAdapters\TestDoubles";s:9:"startLine";i:23;s:7:"endLine";i:34;s:7:"methods";a:2:{s:11:"__construct";a:6:{s:10:"methodName";s:11:"__construct";s:9:"signature";s:27:"__construct(object $driver)";s:10:"visibility";s:6:"public";s:9:"startLine";i:25;s:7:"endLine";i:28;s:3:"ccn";i:1;}s:9:"getDriver";a:6:{s:10:"methodName";s:9:"getDriver";s:9:"signature";s:19:"getDriver(): object";s:10:"visibility";s:6:"public";s:9:"startLine";i:30;s:7:"endLine";i:33;s:3:"ccn";i:1;}}}}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:35;s:18:"commentLinesOfCode";i:13;s:21:"nonCommentLinesOfCode";i:22;}s:15:"ignoredLinesFor";a:1:{i:0;i:23;}s:17:"executableLinesIn";a:2:{i:28;i:1;i:32;i:2;}} \ No newline at end of file diff --git a/.phpunit.cache/code-coverage/60b389e05fdb7163b0f6a5786e31776e b/.phpunit.cache/code-coverage/60b389e05fdb7163b0f6a5786e31776e new file mode 100644 index 0000000..76b47c6 --- /dev/null +++ b/.phpunit.cache/code-coverage/60b389e05fdb7163b0f6a5786e31776e @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:1:{s:56:"Maatify\DataAdapters\Adapters\Mongo\MongoDatabaseAdapter";a:6:{s:4:"name";s:20:"MongoDatabaseAdapter";s:14:"namespacedName";s:56:"Maatify\DataAdapters\Adapters\Mongo\MongoDatabaseAdapter";s:9:"namespace";s:35:"Maatify\DataAdapters\Adapters\Mongo";s:9:"startLine";i:24;s:7:"endLine";i:35;s:7:"methods";a:2:{s:11:"__construct";a:6:{s:10:"methodName";s:11:"__construct";s:9:"signature";s:37:"__construct(MongoDB\Database $driver)";s:10:"visibility";s:6:"public";s:9:"startLine";i:26;s:7:"endLine";i:29;s:3:"ccn";i:1;}s:9:"getDriver";a:6:{s:10:"methodName";s:9:"getDriver";s:9:"signature";s:19:"getDriver(): object";s:10:"visibility";s:6:"public";s:9:"startLine";i:31;s:7:"endLine";i:34;s:3:"ccn";i:1;}}}}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:36;s:18:"commentLinesOfCode";i:13;s:21:"nonCommentLinesOfCode";i:23;}s:15:"ignoredLinesFor";a:1:{i:0;i:24;}s:17:"executableLinesIn";a:2:{i:29;i:1;i:33;i:2;}} \ No newline at end of file diff --git a/.phpunit.cache/code-coverage/66fd479b35873e2edbeeb25d5ad0f3eb b/.phpunit.cache/code-coverage/66fd479b35873e2edbeeb25d5ad0f3eb new file mode 100644 index 0000000..fd28bd5 --- /dev/null +++ b/.phpunit.cache/code-coverage/66fd479b35873e2edbeeb25d5ad0f3eb @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:1:{s:51:"Maatify\DataAdapters\Adapters\MySQL\MySQLPDOAdapter";a:6:{s:4:"name";s:15:"MySQLPDOAdapter";s:14:"namespacedName";s:51:"Maatify\DataAdapters\Adapters\MySQL\MySQLPDOAdapter";s:9:"namespace";s:35:"Maatify\DataAdapters\Adapters\MySQL";s:9:"startLine";i:24;s:7:"endLine";i:35;s:7:"methods";a:2:{s:11:"__construct";a:6:{s:10:"methodName";s:11:"__construct";s:9:"signature";s:24:"__construct(PDO $driver)";s:10:"visibility";s:6:"public";s:9:"startLine";i:26;s:7:"endLine";i:29;s:3:"ccn";i:1;}s:9:"getDriver";a:6:{s:10:"methodName";s:9:"getDriver";s:9:"signature";s:19:"getDriver(): object";s:10:"visibility";s:6:"public";s:9:"startLine";i:31;s:7:"endLine";i:34;s:3:"ccn";i:1;}}}}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:36;s:18:"commentLinesOfCode";i:13;s:21:"nonCommentLinesOfCode";i:23;}s:15:"ignoredLinesFor";a:1:{i:0;i:24;}s:17:"executableLinesIn";a:2:{i:29;i:1;i:33;i:2;}} \ No newline at end of file diff --git a/.phpunit.cache/code-coverage/75aae7a9e985de153114e9f8b356fb60 b/.phpunit.cache/code-coverage/75aae7a9e985de153114e9f8b356fb60 new file mode 100644 index 0000000..942265a --- /dev/null +++ b/.phpunit.cache/code-coverage/75aae7a9e985de153114e9f8b356fb60 @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:1:{s:54:"Maatify\DataAdapters\Adapters\Redis\RedisPredisAdapter";a:6:{s:4:"name";s:18:"RedisPredisAdapter";s:14:"namespacedName";s:54:"Maatify\DataAdapters\Adapters\Redis\RedisPredisAdapter";s:9:"namespace";s:35:"Maatify\DataAdapters\Adapters\Redis";s:9:"startLine";i:24;s:7:"endLine";i:35;s:7:"methods";a:2:{s:11:"__construct";a:6:{s:10:"methodName";s:11:"__construct";s:9:"signature";s:34:"__construct(Predis\Client $driver)";s:10:"visibility";s:6:"public";s:9:"startLine";i:26;s:7:"endLine";i:29;s:3:"ccn";i:1;}s:9:"getDriver";a:6:{s:10:"methodName";s:9:"getDriver";s:9:"signature";s:19:"getDriver(): object";s:10:"visibility";s:6:"public";s:9:"startLine";i:31;s:7:"endLine";i:34;s:3:"ccn";i:1;}}}}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:36;s:18:"commentLinesOfCode";i:13;s:21:"nonCommentLinesOfCode";i:23;}s:15:"ignoredLinesFor";a:1:{i:0;i:24;}s:17:"executableLinesIn";a:2:{i:29;i:1;i:33;i:2;}} \ No newline at end of file diff --git a/.phpunit.cache/code-coverage/87eb048806defb795afe10102f2dda26 b/.phpunit.cache/code-coverage/87eb048806defb795afe10102f2dda26 new file mode 100644 index 0000000..6becdd8 --- /dev/null +++ b/.phpunit.cache/code-coverage/87eb048806defb795afe10102f2dda26 @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:1:{s:48:"Maatify\DataAdapters\Adapters\Redis\RedisAdapter";a:6:{s:4:"name";s:12:"RedisAdapter";s:14:"namespacedName";s:48:"Maatify\DataAdapters\Adapters\Redis\RedisAdapter";s:9:"namespace";s:35:"Maatify\DataAdapters\Adapters\Redis";s:9:"startLine";i:24;s:7:"endLine";i:35;s:7:"methods";a:2:{s:11:"__construct";a:6:{s:10:"methodName";s:11:"__construct";s:9:"signature";s:26:"__construct(Redis $driver)";s:10:"visibility";s:6:"public";s:9:"startLine";i:26;s:7:"endLine";i:29;s:3:"ccn";i:1;}s:9:"getDriver";a:6:{s:10:"methodName";s:9:"getDriver";s:9:"signature";s:19:"getDriver(): object";s:10:"visibility";s:6:"public";s:9:"startLine";i:31;s:7:"endLine";i:34;s:3:"ccn";i:1;}}}}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:36;s:18:"commentLinesOfCode";i:13;s:21:"nonCommentLinesOfCode";i:23;}s:15:"ignoredLinesFor";a:1:{i:0;i:24;}s:17:"executableLinesIn";a:2:{i:29;i:1;i:33;i:2;}} \ No newline at end of file diff --git a/.phpunit.cache/code-coverage/8b2045970bc7afefb207b2035c3ed60d b/.phpunit.cache/code-coverage/8b2045970bc7afefb207b2035c3ed60d new file mode 100644 index 0000000..257db25 --- /dev/null +++ b/.phpunit.cache/code-coverage/8b2045970bc7afefb207b2035c3ed60d @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:1:{s:56:"Maatify\DataAdapters\Exceptions\AdapterCreationException";a:6:{s:4:"name";s:24:"AdapterCreationException";s:14:"namespacedName";s:56:"Maatify\DataAdapters\Exceptions\AdapterCreationException";s:9:"namespace";s:31:"Maatify\DataAdapters\Exceptions";s:9:"startLine";i:21;s:7:"endLine";i:29;s:7:"methods";a:1:{s:11:"__construct";a:6:{s:10:"methodName";s:11:"__construct";s:9:"signature";s:50:"__construct(string $message, ?Throwable $previous)";s:10:"visibility";s:6:"public";s:9:"startLine";i:23;s:7:"endLine";i:28;s:3:"ccn";i:1;}}}}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:30;s:18:"commentLinesOfCode";i:10;s:21:"nonCommentLinesOfCode";i:20;}s:15:"ignoredLinesFor";a:1:{i:0;i:21;}s:17:"executableLinesIn";a:1:{i:27;i:1;}} \ No newline at end of file diff --git a/.phpunit.cache/code-coverage/93d522a0159c1206ff7ae6c931ae6015 b/.phpunit.cache/code-coverage/93d522a0159c1206ff7ae6c931ae6015 new file mode 100644 index 0000000..ba661ee --- /dev/null +++ b/.phpunit.cache/code-coverage/93d522a0159c1206ff7ae6c931ae6015 @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:1:{s:50:"Maatify\DataAdapters\Factories\RedisAdapterFactory";a:6:{s:4:"name";s:19:"RedisAdapterFactory";s:14:"namespacedName";s:50:"Maatify\DataAdapters\Factories\RedisAdapterFactory";s:9:"namespace";s:30:"Maatify\DataAdapters\Factories";s:9:"startLine";i:24;s:7:"endLine";i:52;s:7:"methods";a:3:{s:9:"fromRedis";a:6:{s:10:"methodName";s:9:"fromRedis";s:9:"signature";s:73:"fromRedis(Redis $redis): Maatify\DataAdapters\Adapters\Redis\RedisAdapter";s:10:"visibility";s:6:"public";s:9:"startLine";i:26;s:7:"endLine";i:29;s:3:"ccn";i:1;}s:10:"fromPredis";a:6:{s:10:"methodName";s:10:"fromPredis";s:9:"signature";s:89:"fromPredis(Predis\Client $client): Maatify\DataAdapters\Adapters\Redis\RedisPredisAdapter";s:10:"visibility";s:6:"public";s:9:"startLine";i:31;s:7:"endLine";i:34;s:3:"ccn";i:1;}s:16:"fromRedisFactory";a:6:{s:10:"methodName";s:16:"fromRedisFactory";s:9:"signature";s:90:"fromRedisFactory(callable $redisFactory): Maatify\DataAdapters\Adapters\Redis\RedisAdapter";s:10:"visibility";s:6:"public";s:9:"startLine";i:39;s:7:"endLine";i:51;s:3:"ccn";i:2;}}}}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:53;s:18:"commentLinesOfCode";i:13;s:21:"nonCommentLinesOfCode";i:40;}s:15:"ignoredLinesFor";a:1:{i:0;i:24;}s:17:"executableLinesIn";a:9:{i:28;i:1;i:33;i:2;i:42;i:3;i:44;i:4;i:45;i:5;i:49;i:7;i:46;i:7;i:47;i:7;i:48;i:7;}} \ No newline at end of file diff --git a/.phpunit.cache/code-coverage/9835b14ca8f70d42be41fe1cc250ef7d b/.phpunit.cache/code-coverage/9835b14ca8f70d42be41fe1cc250ef7d new file mode 100644 index 0000000..5b04f5f --- /dev/null +++ b/.phpunit.cache/code-coverage/9835b14ca8f70d42be41fe1cc250ef7d @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:1:{s:50:"Maatify\DataAdapters\Factories\MongoAdapterFactory";a:6:{s:4:"name";s:19:"MongoAdapterFactory";s:14:"namespacedName";s:50:"Maatify\DataAdapters\Factories\MongoAdapterFactory";s:9:"namespace";s:30:"Maatify\DataAdapters\Factories";s:9:"startLine";i:22;s:7:"endLine";i:47;s:7:"methods";a:2:{s:12:"fromDatabase";a:6:{s:10:"methodName";s:12:"fromDatabase";s:9:"signature";s:98:"fromDatabase(MongoDB\Database $database): Maatify\DataAdapters\Adapters\Mongo\MongoDatabaseAdapter";s:10:"visibility";s:6:"public";s:9:"startLine";i:24;s:7:"endLine";i:27;s:3:"ccn";i:1;}s:19:"fromDatabaseFactory";a:6:{s:10:"methodName";s:19:"fromDatabaseFactory";s:9:"signature";s:104:"fromDatabaseFactory(callable $databaseFactory): Maatify\DataAdapters\Adapters\Mongo\MongoDatabaseAdapter";s:10:"visibility";s:6:"public";s:9:"startLine";i:34;s:7:"endLine";i:46;s:3:"ccn";i:2;}}}}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:48;s:18:"commentLinesOfCode";i:15;s:21:"nonCommentLinesOfCode";i:33;}s:15:"ignoredLinesFor";a:1:{i:0;i:22;}s:17:"executableLinesIn";a:8:{i:26;i:1;i:37;i:2;i:39;i:3;i:40;i:4;i:44;i:6;i:41;i:6;i:42;i:6;i:43;i:6;}} \ No newline at end of file diff --git a/.phpunit.cache/code-coverage/c9adb23fd4b1e618ad999f206c25c732 b/.phpunit.cache/code-coverage/c9adb23fd4b1e618ad999f206c25c732 new file mode 100644 index 0000000..58810bc --- /dev/null +++ b/.phpunit.cache/code-coverage/c9adb23fd4b1e618ad999f206c25c732 @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:1:{s:50:"Maatify\DataAdapters\Factories\MySQLAdapterFactory";a:6:{s:4:"name";s:19:"MySQLAdapterFactory";s:14:"namespacedName";s:50:"Maatify\DataAdapters\Factories\MySQLAdapterFactory";s:9:"namespace";s:30:"Maatify\DataAdapters\Factories";s:9:"startLine";i:25;s:7:"endLine";i:56;s:7:"methods";a:3:{s:7:"fromPDO";a:6:{s:10:"methodName";s:7:"fromPDO";s:9:"signature";s:70:"fromPDO(PDO $pdo): Maatify\DataAdapters\Adapters\MySQL\MySQLPDOAdapter";s:10:"visibility";s:6:"public";s:9:"startLine";i:27;s:7:"endLine";i:30;s:3:"ccn";i:1;}s:8:"fromDBAL";a:6:{s:10:"methodName";s:8:"fromDBAL";s:9:"signature";s:100:"fromDBAL(Doctrine\DBAL\Connection $connection): Maatify\DataAdapters\Adapters\MySQL\MySQLDBALAdapter";s:10:"visibility";s:6:"public";s:9:"startLine";i:32;s:7:"endLine";i:35;s:3:"ccn";i:1;}s:14:"fromPDOFactory";a:6:{s:10:"methodName";s:14:"fromPDOFactory";s:9:"signature";s:89:"fromPDOFactory(callable $pdoFactory): Maatify\DataAdapters\Adapters\MySQL\MySQLPDOAdapter";s:10:"visibility";s:6:"public";s:9:"startLine";i:43;s:7:"endLine";i:55;s:3:"ccn";i:2;}}}}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:57;s:18:"commentLinesOfCode";i:16;s:21:"nonCommentLinesOfCode";i:41;}s:15:"ignoredLinesFor";a:1:{i:0;i:25;}s:17:"executableLinesIn";a:9:{i:29;i:1;i:34;i:2;i:46;i:3;i:48;i:4;i:49;i:5;i:53;i:7;i:50;i:7;i:51;i:7;i:52;i:7;}} \ No newline at end of file diff --git a/.phpunit.cache/code-coverage/fad07a57a8c027da63689cdc2cc54eeb b/.phpunit.cache/code-coverage/fad07a57a8c027da63689cdc2cc54eeb new file mode 100644 index 0000000..6f0c5f6 --- /dev/null +++ b/.phpunit.cache/code-coverage/fad07a57a8c027da63689cdc2cc54eeb @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:0:{}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:44;s:18:"commentLinesOfCode";i:32;s:21:"nonCommentLinesOfCode";i:12;}s:15:"ignoredLinesFor";a:1:{i:0;i:35;}s:17:"executableLinesIn";a:0:{}} \ No newline at end of file diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results new file mode 100644 index 0000000..ae93ede --- /dev/null +++ b/.phpunit.cache/test-results @@ -0,0 +1 @@ +{"version":2,"defects":[],"times":{"Maatify\\DataAdapters\\Tests\\Adapters\\Redis\\RedisAdapterTest::testConstructorAcceptsRedisAndGetDriverReturnsIt":0.002,"Maatify\\DataAdapters\\Tests\\Factories\\RedisAdapterFactoryTest::testFromRedisCreatesAdapter":0.067,"Maatify\\DataAdapters\\Tests\\Factories\\RedisAdapterFactoryTest::testFromRedisFactoryThrowsAdapterCreationExceptionWhenCallableFails":0.002,"Maatify\\DataAdapters\\Tests\\Factories\\RedisAdapterFactoryTest::testFromPredisCreatesAdapter":0.007,"Maatify\\DataAdapters\\Tests\\Factories\\RedisAdapterFactoryTest::testFromRedisFactoryCreatesAdapterWhenCallableSucceeds":0.002,"Maatify\\DataAdapters\\Tests\\Factories\\TempTest::testExpectExceptionObject":0.003,"Maatify\\DataAdapters\\Tests\\Factories\\MySQLAdapterFactoryTest::testFromPDOFactoryCreatesAdapterWhenCallableSucceeds":0.002,"Maatify\\DataAdapters\\Tests\\Factories\\MySQLAdapterFactoryTest::testFromPDOFactoryThrowsAdapterCreationExceptionWhenCallableFails":0.002,"Maatify\\DataAdapters\\Tests\\Factories\\MySQLAdapterFactoryTest::testFromDBALCreatesAdapter":0.024,"Maatify\\DataAdapters\\Tests\\Factories\\MySQLAdapterFactoryTest::testFromPDOCreatesAdapter":0.004,"Maatify\\DataAdapters\\Tests\\Factories\\MongoAdapterFactoryTest::testFromDatabaseFactoryCreatesAdapterWhenCallableSucceeds":0.002,"Maatify\\DataAdapters\\Tests\\Factories\\MongoAdapterFactoryTest::testFromDatabaseCreatesAdapter":0.003,"Maatify\\DataAdapters\\Tests\\Factories\\MongoAdapterFactoryTest::testFromDatabaseFactoryThrowsAdapterCreationExceptionWhenCallableFails":0.003,"Maatify\\DataAdapters\\Tests\\Adapters\\MySQL\\MySQLDBALAdapterTest::testConstructorAcceptsConnectionAndGetDriverReturnsIt":0.002,"Maatify\\DataAdapters\\Tests\\Adapters\\MySQL\\MySQLPDOAdapterTest::testConstructorAcceptsPDOAndGetDriverReturnsIt":0.002,"Maatify\\DataAdapters\\Tests\\Contract\\AdapterInterfaceTest::testGetDriverExistsAndReturnsObject":0.003,"Maatify\\DataAdapters\\Tests\\Adapters\\Mongo\\MongoDatabaseAdapterTest::testConstructorAcceptsDatabaseAndGetDriverReturnsIt":0.051,"Maatify\\DataAdapters\\Tests\\Adapters\\Redis\\RedisPredisAdapterTest::testConstructorAcceptsClientAndGetDriverReturnsIt":0.002}} \ No newline at end of file diff --git a/tests/Adapters/Mongo/MongoDatabaseAdapterTest.php b/tests/Adapters/Mongo/MongoDatabaseAdapterTest.php new file mode 100644 index 0000000..0087724 --- /dev/null +++ b/tests/Adapters/Mongo/MongoDatabaseAdapterTest.php @@ -0,0 +1,22 @@ +createMock(Database::class); + $adapter = new MongoDatabaseAdapter($database); + + $this->assertInstanceOf(AdapterInterface::class, $adapter); + $this->assertSame($database, $adapter->getDriver()); + } +} diff --git a/tests/Adapters/MongoDatabaseAdapterTest.php b/tests/Adapters/MongoDatabaseAdapterTest.php deleted file mode 100644 index 5ac3fc1..0000000 --- a/tests/Adapters/MongoDatabaseAdapterTest.php +++ /dev/null @@ -1,54 +0,0 @@ -markTestSkipped('MongoDB\Database class is not available.'); - } - } - - public function test_it_implements_adapter_interface(): void - { - $driver = $this->createStub('MongoDB\Database'); - $adapter = new MongoDatabaseAdapter($driver); - - $this->assertInstanceOf(AdapterInterface::class, $adapter); - } - - public function test_construction_and_get_driver(): void - { - $driver = $this->createStub('MongoDB\Database'); - $adapter = new MongoDatabaseAdapter($driver); - - $this->assertSame($driver, $adapter->getDriver()); - } - - public function test_get_driver_returns_correct_type(): void - { - $driver = $this->createStub('MongoDB\Database'); - $adapter = new MongoDatabaseAdapter($driver); - - $this->assertInstanceOf('MongoDB\Database', $adapter->getDriver()); - } - - public function test_repeated_calls_return_same_instance(): void - { - $driver = $this->createStub('MongoDB\Database'); - $adapter = new MongoDatabaseAdapter($driver); - - $first = $adapter->getDriver(); - $second = $adapter->getDriver(); - - $this->assertSame($first, $second); - } -} diff --git a/tests/Adapters/MySQL/MySQLDBALAdapterTest.php b/tests/Adapters/MySQL/MySQLDBALAdapterTest.php new file mode 100644 index 0000000..496de2c --- /dev/null +++ b/tests/Adapters/MySQL/MySQLDBALAdapterTest.php @@ -0,0 +1,22 @@ +createMock(Connection::class); + $adapter = new MySQLDBALAdapter($connection); + + $this->assertInstanceOf(AdapterInterface::class, $adapter); + $this->assertSame($connection, $adapter->getDriver()); + } +} diff --git a/tests/Adapters/MySQL/MySQLPDOAdapterTest.php b/tests/Adapters/MySQL/MySQLPDOAdapterTest.php new file mode 100644 index 0000000..fe545a3 --- /dev/null +++ b/tests/Adapters/MySQL/MySQLPDOAdapterTest.php @@ -0,0 +1,22 @@ +createMock(PDO::class); + $adapter = new MySQLPDOAdapter($pdo); + + $this->assertInstanceOf(AdapterInterface::class, $adapter); + $this->assertSame($pdo, $adapter->getDriver()); + } +} diff --git a/tests/Adapters/MySQLDBALAdapterTest.php b/tests/Adapters/MySQLDBALAdapterTest.php deleted file mode 100644 index c698f34..0000000 --- a/tests/Adapters/MySQLDBALAdapterTest.php +++ /dev/null @@ -1,54 +0,0 @@ -markTestSkipped('Doctrine DBAL Connection class is not available.'); - } - } - - public function test_it_implements_adapter_interface(): void - { - $driver = $this->createStub('Doctrine\DBAL\Connection'); - $adapter = new MySQLDBALAdapter($driver); - - $this->assertInstanceOf(AdapterInterface::class, $adapter); - } - - public function test_construction_and_get_driver(): void - { - $driver = $this->createStub('Doctrine\DBAL\Connection'); - $adapter = new MySQLDBALAdapter($driver); - - $this->assertSame($driver, $adapter->getDriver()); - } - - public function test_get_driver_returns_correct_type(): void - { - $driver = $this->createStub('Doctrine\DBAL\Connection'); - $adapter = new MySQLDBALAdapter($driver); - - $this->assertInstanceOf('Doctrine\DBAL\Connection', $adapter->getDriver()); - } - - public function test_repeated_calls_return_same_instance(): void - { - $driver = $this->createStub('Doctrine\DBAL\Connection'); - $adapter = new MySQLDBALAdapter($driver); - - $first = $adapter->getDriver(); - $second = $adapter->getDriver(); - - $this->assertSame($first, $second); - } -} diff --git a/tests/Adapters/MySQLPDOAdapterTest.php b/tests/Adapters/MySQLPDOAdapterTest.php deleted file mode 100644 index cd06720..0000000 --- a/tests/Adapters/MySQLPDOAdapterTest.php +++ /dev/null @@ -1,54 +0,0 @@ -markTestSkipped('PDO class is not available.'); - } - } - - public function test_it_implements_adapter_interface(): void - { - $driver = $this->createStub(\PDO::class); - $adapter = new MySQLPDOAdapter($driver); - - $this->assertInstanceOf(AdapterInterface::class, $adapter); - } - - public function test_construction_and_get_driver(): void - { - $driver = $this->createStub(\PDO::class); - $adapter = new MySQLPDOAdapter($driver); - - $this->assertSame($driver, $adapter->getDriver()); - } - - public function test_get_driver_returns_correct_type(): void - { - $driver = $this->createStub(\PDO::class); - $adapter = new MySQLPDOAdapter($driver); - - $this->assertInstanceOf(\PDO::class, $adapter->getDriver()); - } - - public function test_repeated_calls_return_same_instance(): void - { - $driver = $this->createStub(\PDO::class); - $adapter = new MySQLPDOAdapter($driver); - - $first = $adapter->getDriver(); - $second = $adapter->getDriver(); - - $this->assertSame($first, $second); - } -} diff --git a/tests/Adapters/Redis/RedisAdapterTest.php b/tests/Adapters/Redis/RedisAdapterTest.php new file mode 100644 index 0000000..7bfed39 --- /dev/null +++ b/tests/Adapters/Redis/RedisAdapterTest.php @@ -0,0 +1,26 @@ +markTestSkipped('Redis extension not loaded.'); + } + + $redis = $this->createMock(Redis::class); + $adapter = new RedisAdapter($redis); + + $this->assertInstanceOf(AdapterInterface::class, $adapter); + $this->assertSame($redis, $adapter->getDriver()); + } +} diff --git a/tests/Adapters/Redis/RedisPredisAdapterTest.php b/tests/Adapters/Redis/RedisPredisAdapterTest.php new file mode 100644 index 0000000..6bbc48d --- /dev/null +++ b/tests/Adapters/Redis/RedisPredisAdapterTest.php @@ -0,0 +1,22 @@ +createMock(Client::class); + $adapter = new RedisPredisAdapter($client); + + $this->assertInstanceOf(AdapterInterface::class, $adapter); + $this->assertSame($client, $adapter->getDriver()); + } +} diff --git a/tests/Adapters/RedisAdapterTest.php b/tests/Adapters/RedisAdapterTest.php deleted file mode 100644 index d2e0b85..0000000 --- a/tests/Adapters/RedisAdapterTest.php +++ /dev/null @@ -1,54 +0,0 @@ -markTestSkipped('Redis class is not available.'); - } - } - - public function test_it_implements_adapter_interface(): void - { - $driver = $this->createStub(\Redis::class); - $adapter = new RedisAdapter($driver); - - $this->assertInstanceOf(AdapterInterface::class, $adapter); - } - - public function test_construction_and_get_driver(): void - { - $driver = $this->createStub(\Redis::class); - $adapter = new RedisAdapter($driver); - - $this->assertSame($driver, $adapter->getDriver()); - } - - public function test_get_driver_returns_correct_type(): void - { - $driver = $this->createStub(\Redis::class); - $adapter = new RedisAdapter($driver); - - $this->assertInstanceOf(\Redis::class, $adapter->getDriver()); - } - - public function test_repeated_calls_return_same_instance(): void - { - $driver = $this->createStub(\Redis::class); - $adapter = new RedisAdapter($driver); - - $first = $adapter->getDriver(); - $second = $adapter->getDriver(); - - $this->assertSame($first, $second); - } -} diff --git a/tests/Adapters/RedisPredisAdapterTest.php b/tests/Adapters/RedisPredisAdapterTest.php deleted file mode 100644 index 55de73c..0000000 --- a/tests/Adapters/RedisPredisAdapterTest.php +++ /dev/null @@ -1,54 +0,0 @@ -markTestSkipped('Predis\Client class is not available.'); - } - } - - public function test_it_implements_adapter_interface(): void - { - $driver = $this->createStub('Predis\Client'); - $adapter = new RedisPredisAdapter($driver); - - $this->assertInstanceOf(AdapterInterface::class, $adapter); - } - - public function test_construction_and_get_driver(): void - { - $driver = $this->createStub('Predis\Client'); - $adapter = new RedisPredisAdapter($driver); - - $this->assertSame($driver, $adapter->getDriver()); - } - - public function test_get_driver_returns_correct_type(): void - { - $driver = $this->createStub('Predis\Client'); - $adapter = new RedisPredisAdapter($driver); - - $this->assertInstanceOf('Predis\Client', $adapter->getDriver()); - } - - public function test_repeated_calls_return_same_instance(): void - { - $driver = $this->createStub('Predis\Client'); - $adapter = new RedisPredisAdapter($driver); - - $first = $adapter->getDriver(); - $second = $adapter->getDriver(); - - $this->assertSame($first, $second); - } -} diff --git a/tests/Contract/AbstractAdapterContract.php b/tests/Contract/AbstractAdapterContract.php deleted file mode 100644 index fac36f6..0000000 --- a/tests/Contract/AbstractAdapterContract.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @since 2025-12-17 03:57 - * @see https://www.maatify.dev Maatify.dev - * @link https://github.com/Maatify/data-adapters view Project on GitHub - * @note Distributed in the hope that it will be useful - WITHOUT WARRANTY. - */ - -declare(strict_types=1); - -namespace Maatify\DataAdapters\Tests\Contract; - -use Maatify\DataAdapters\Contracts\Adapter\AdapterInterface; -use PHPUnit\Framework\TestCase; - -abstract class AbstractAdapterContract extends TestCase -{ - /** - * كل Adapter لازم يوفّر instance جاهز - */ - abstract protected function createAdapter(): AdapterInterface; - - public function test_it_returns_a_driver_object(): void - { - $adapter = $this->createAdapter(); - - $driver = $adapter->getDriver(); - - $this->assertIsObject( - $driver, - 'Adapter::getDriver() must return an object' - ); - } - - public function test_it_returns_the_same_driver_instance(): void - { - $adapter = $this->createAdapter(); - - $first = $adapter->getDriver(); - $second = $adapter->getDriver(); - - $this->assertSame( - $first, - $second, - 'Adapter must not recreate or mutate the driver instance' - ); - } - - public function test_adapter_does_not_expose_magic_methods(): void - { - $adapter = $this->createAdapter(); - - $this->assertFalse( - method_exists($adapter, '__call'), - 'Adapters must not use magic method __call' - ); - } -} diff --git a/tests/Contract/AdapterInterfaceTest.php b/tests/Contract/AdapterInterfaceTest.php new file mode 100644 index 0000000..3dd9677 --- /dev/null +++ b/tests/Contract/AdapterInterfaceTest.php @@ -0,0 +1,25 @@ +assertInstanceOf(AdapterInterface::class, $adapter); + $this->assertTrue(method_exists($adapter, 'getDriver')); + + $returnedDriver = $adapter->getDriver(); + $this->assertIsObject($returnedDriver); + $this->assertSame($driver, $returnedDriver); + } +} diff --git a/tests/Contract/DummyAbstractAdapter.php b/tests/Contract/DummyAbstractAdapter.php deleted file mode 100644 index 95bcca6..0000000 --- a/tests/Contract/DummyAbstractAdapter.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @since 2025-12-17 03:58 - * @see https://www.maatify.dev Maatify.dev - * @link https://github.com/Maatify/data-adapters view Project on GitHub - * @note Distributed in the hope that it will be useful - WITHOUT WARRANTY. - */ - -declare(strict_types=1); - -namespace Maatify\DataAdapters\Tests\Contract; - -use Maatify\DataAdapters\Contracts\Adapter\AdapterInterface; -use Maatify\DataAdapters\TestDoubles\DummyAdapter; - -final class DummyAbstractAdapter extends AbstractAdapterContract -{ - protected function createAdapter(): AdapterInterface - { - return new DummyAdapter(new \stdClass()); - } -} diff --git a/tests/Factories/MongoAdapterFactoryTest.php b/tests/Factories/MongoAdapterFactoryTest.php new file mode 100644 index 0000000..424665b --- /dev/null +++ b/tests/Factories/MongoAdapterFactoryTest.php @@ -0,0 +1,51 @@ +createMock(Database::class); + $adapter = MongoAdapterFactory::fromDatabase($database); + + $this->assertInstanceOf(MongoDatabaseAdapter::class, $adapter); + $this->assertSame($database, $adapter->getDriver()); + } + + public function testFromDatabaseFactoryCreatesAdapterWhenCallableSucceeds(): void + { + $database = $this->createMock(Database::class); + $factory = fn () => $database; + + $adapter = MongoAdapterFactory::fromDatabaseFactory($factory); + + $this->assertInstanceOf(MongoDatabaseAdapter::class, $adapter); + $this->assertSame($database, $adapter->getDriver()); + } + + public function testFromDatabaseFactoryThrowsAdapterCreationExceptionWhenCallableFails(): void + { + $originalException = new RuntimeException('fail'); + $factory = fn () => throw $originalException; + + $this->expectException(AdapterCreationException::class); + $this->expectExceptionMessage('Failed to create MongoDB adapter'); + + try { + MongoAdapterFactory::fromDatabaseFactory($factory); + } catch (AdapterCreationException $e) { + $this->assertSame($originalException, $e->getPrevious()); + throw $e; + } + } +} diff --git a/tests/Factories/MySQLAdapterFactoryTest.php b/tests/Factories/MySQLAdapterFactoryTest.php new file mode 100644 index 0000000..0f3e8de --- /dev/null +++ b/tests/Factories/MySQLAdapterFactoryTest.php @@ -0,0 +1,62 @@ +createMock(PDO::class); + $adapter = MySQLAdapterFactory::fromPDO($pdo); + + $this->assertInstanceOf(MySQLPDOAdapter::class, $adapter); + $this->assertSame($pdo, $adapter->getDriver()); + } + + public function testFromDBALCreatesAdapter(): void + { + $connection = $this->createMock(Connection::class); + $adapter = MySQLAdapterFactory::fromDBAL($connection); + + $this->assertInstanceOf(MySQLDBALAdapter::class, $adapter); + $this->assertSame($connection, $adapter->getDriver()); + } + + public function testFromPDOFactoryCreatesAdapterWhenCallableSucceeds(): void + { + $pdo = $this->createMock(PDO::class); + $factory = fn () => $pdo; + + $adapter = MySQLAdapterFactory::fromPDOFactory($factory); + + $this->assertInstanceOf(MySQLPDOAdapter::class, $adapter); + $this->assertSame($pdo, $adapter->getDriver()); + } + + public function testFromPDOFactoryThrowsAdapterCreationExceptionWhenCallableFails(): void + { + $originalException = new RuntimeException('fail'); + $factory = fn () => throw $originalException; + + $this->expectException(AdapterCreationException::class); + $this->expectExceptionMessage('Failed to create PDO-based MySQL adapter'); + + try { + MySQLAdapterFactory::fromPDOFactory($factory); + } catch (AdapterCreationException $e) { + $this->assertSame($originalException, $e->getPrevious()); + throw $e; + } + } +} diff --git a/tests/Factories/RedisAdapterFactoryTest.php b/tests/Factories/RedisAdapterFactoryTest.php new file mode 100644 index 0000000..4207c33 --- /dev/null +++ b/tests/Factories/RedisAdapterFactoryTest.php @@ -0,0 +1,70 @@ +markTestSkipped('Redis extension not loaded.'); + } + + $redis = $this->createMock(Redis::class); + $adapter = RedisAdapterFactory::fromRedis($redis); + + $this->assertInstanceOf(RedisAdapter::class, $adapter); + $this->assertSame($redis, $adapter->getDriver()); + } + + public function testFromPredisCreatesAdapter(): void + { + $client = $this->createMock(Client::class); + $adapter = RedisAdapterFactory::fromPredis($client); + + $this->assertInstanceOf(RedisPredisAdapter::class, $adapter); + $this->assertSame($client, $adapter->getDriver()); + } + + public function testFromRedisFactoryCreatesAdapterWhenCallableSucceeds(): void + { + if (!class_exists(Redis::class)) { + $this->markTestSkipped('Redis extension not loaded.'); + } + + $redis = $this->createMock(Redis::class); + $factory = fn () => $redis; + + $adapter = RedisAdapterFactory::fromRedisFactory($factory); + + $this->assertInstanceOf(RedisAdapter::class, $adapter); + $this->assertSame($redis, $adapter->getDriver()); + } + + public function testFromRedisFactoryThrowsAdapterCreationExceptionWhenCallableFails(): void + { + $originalException = new RuntimeException('fail'); + $factory = fn () => throw $originalException; + + $this->expectException(AdapterCreationException::class); + $this->expectExceptionMessage('Failed to create ext-redis adapter'); + + try { + RedisAdapterFactory::fromRedisFactory($factory); + } catch (AdapterCreationException $e) { + $this->assertSame($originalException, $e->getPrevious()); + throw $e; + } + } +}