-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '5.0.x' into #15363-fix-db-delete
# Conflicts: # CHANGELOG-5.0.md
- Loading branch information
Showing
11 changed files
with
263 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ | |
|
||
use DatabaseTester; | ||
use PDO; | ||
use Phalcon\Cache; | ||
use Phalcon\Cache\AdapterFactory; | ||
use Phalcon\Mvc\Model\Exception; | ||
use Phalcon\Storage\SerializerFactory; | ||
use Phalcon\Test\Fixtures\Migrations\CustomersMigration; | ||
use Phalcon\Test\Fixtures\Migrations\ObjectsMigration; | ||
|
@@ -104,8 +106,9 @@ public function mvcModelFindWithCache(DatabaseTester $I) | |
$serializerFactory = new SerializerFactory(); | ||
$adapterFactory = new AdapterFactory($serializerFactory); | ||
$adapter = $adapterFactory->newInstance('stream', $options); | ||
$cache = new Cache($adapter); | ||
|
||
$this->container->setShared('modelsCache', $adapter); | ||
$this->container->setShared('modelsCache', $cache); | ||
|
||
/** | ||
* Get the records (should cache the resultset) | ||
|
@@ -175,10 +178,7 @@ public function mvcModelFindResultsetSecondIteration(DatabaseTester $I) | |
|
||
$customers = Customers::find(); | ||
|
||
$I->assertCount( | ||
2, | ||
$customers | ||
); | ||
$I->assertCount(2, $customers); | ||
|
||
/** | ||
* First iteration | ||
|
@@ -210,4 +210,47 @@ public function mvcModelFindResultsetSecondIteration(DatabaseTester $I) | |
); | ||
} | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Mvc\Model :: find() - with cache/exception | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2021-05-10 | ||
* | ||
* @group mysql | ||
* @group pgsql | ||
* @group sqlite | ||
*/ | ||
public function mvcModelFindWithCacheException(DatabaseTester $I) | ||
{ | ||
$I->wantToTest('Mvc\Model - find() - with cache - exception'); | ||
|
||
$I->expectThrowable( | ||
new Exception( | ||
'Cache service must be an object implementing Psr\SimpleCache\CacheInterface' | ||
), | ||
function () { | ||
$options = [ | ||
'storageDir' => outputDir(), | ||
'lifetime' => 172800, | ||
'prefix' => 'data-', | ||
]; | ||
|
||
// Models Cache setup | ||
$serializerFactory = new SerializerFactory(); | ||
$adapterFactory = new AdapterFactory($serializerFactory); | ||
$adapter = $adapterFactory->newInstance('stream', $options); | ||
|
||
$this->container->setShared('modelsCache', $adapter); | ||
|
||
Objects::find( | ||
[ | ||
'cache' => [ | ||
'key' => 'my-cache', | ||
], | ||
] | ||
); | ||
} | ||
); | ||
} | ||
} |
Oops, something went wrong.