-
-
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.
[#13439] - Added more tests for Cache AdapterFactory
- Loading branch information
Showing
4 changed files
with
150 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalconphp.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Cache\AdapterFactory; | ||
|
||
use Phalcon\Cache\AdapterFactory; | ||
use Phalcon\Storage\SerializerFactory; | ||
use UnitTester; | ||
|
||
class ConstructCest | ||
{ | ||
/** | ||
* Tests Phalcon\Cache\AdapterFactory :: __construct() | ||
* | ||
* @author Phalcon Team <team@phalconphp.com> | ||
* @since 2019-05-04 | ||
*/ | ||
public function storageAdapterFactoryConstruct(UnitTester $I) | ||
{ | ||
$I->wantToTest('Cache\AdapterFactory - __construct()'); | ||
|
||
$factory = new SerializerFactory(); | ||
$service = new AdapterFactory($factory); | ||
$I->assertInstanceOf(AdapterFactory::class, $service); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalconphp.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Cache\AdapterFactory; | ||
|
||
use Phalcon\Cache\AdapterFactory; | ||
use Phalcon\Storage\SerializerFactory; | ||
use Phalcon\Test\Fixtures\Cache\Adapter\None; | ||
use UnitTester; | ||
|
||
class GetSetHasCest | ||
{ | ||
/** | ||
* Tests Phalcon\Cache\AdapterFactory :: get() | ||
* | ||
* @author Phalcon Team <team@phalconphp.com> | ||
* @since 2019-05-04 | ||
*/ | ||
public function storageAdapterFactoryGetSetHas(UnitTester $I) | ||
{ | ||
$I->wantToTest('Cache\AdapterFactory - get()/set()/has()'); | ||
$I->skipTest('TODO - Check this'); | ||
$mappers = ['none' => 'Phalcon\Test\Fixtures\Cache\Adapter\None']; | ||
$factory = new SerializerFactory(); | ||
$service = new AdapterFactory($factory, $mappers); | ||
|
||
$actual = $service->has('unknown'); | ||
$I->assertFalse($actual); | ||
|
||
$actual = $service->has('none'); | ||
$I->assertTrue($actual); | ||
|
||
$actual = $service->has('redis'); | ||
$I->assertTrue($actual); | ||
|
||
$actual = $service->get('none'); | ||
$class = None::class; | ||
$I->assertInstanceOf($class, $actual); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalconphp.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Cache\AdapterFactory; | ||
|
||
use Phalcon\Service\Exception; | ||
use Phalcon\Cache\Adapter\Apcu; | ||
use Phalcon\Cache\Adapter\Php; | ||
use Phalcon\Cache\AdapterFactory; | ||
use Phalcon\Storage\SerializerFactory; | ||
use UnitTester; | ||
|
||
class NewInstanceCest | ||
{ | ||
/** | ||
* Tests Phalcon\Cache\AdapterFactory :: newInstance() | ||
* | ||
* @author Phalcon Team <team@phalconphp.com> | ||
* @since 2019-05-04 | ||
*/ | ||
public function storageAdapterFactoryNewInstance(UnitTester $I) | ||
{ | ||
$I->wantToTest('Cache\AdapterFactory - newInstance()'); | ||
|
||
$factory = new SerializerFactory(); | ||
$service = new AdapterFactory($factory); | ||
|
||
$service = $service->newInstance('apcu'); | ||
$class = Apcu::class; | ||
$I->assertInstanceOf($class, $service); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Cache\AdapterFactory :: newInstance() - exception | ||
* | ||
* @author Phalcon Team <team@phalconphp.com> | ||
* @since 2019-05-04 | ||
*/ | ||
public function storageAdapterFactoryNewInstanceException(UnitTester $I) | ||
{ | ||
$I->wantToTest('Cache\AdapterFactory - newInstance() - exception'); | ||
|
||
$I->expectThrowable( | ||
new Exception('The service unknown has not been found in the locator'), | ||
function () { | ||
$factory = new SerializerFactory(); | ||
$service = new AdapterFactory($factory); | ||
$service = $service->newInstance('unknown'); | ||
} | ||
); | ||
} | ||
} |
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