Navigation Menu

Skip to content

Commit

Permalink
[phalcon#12921] - Corrected tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed Dec 17, 2018
1 parent 13572fa commit e07421d
Show file tree
Hide file tree
Showing 22 changed files with 223 additions and 19 deletions.
2 changes: 1 addition & 1 deletion phalcon/di/factorydefault.zep
Expand Up @@ -38,7 +38,7 @@ class FactoryDefault extends \Phalcon\Di

let this->_services = [
"annotations": new Service("Phalcon\\Annotations\\Adapter\\Memory", true),
"assets": new Service("Phalcon\\Assets\\Manager", true)
"assets": new Service("Phalcon\\Assets\\Manager", true),
"crypt": new Service("Phalcon\\Crypt", true),
"cookies": new Service("Phalcon\\Http\\Response\\Cookies", true),
"dispatcher": new Service("Phalcon\\Mvc\\Dispatcher", true),
Expand Down
46 changes: 46 additions & 0 deletions tests/_data/fixtures/Traits/SessionBagTrait.php
@@ -0,0 +1,46 @@
<?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\Fixtures\Traits;

use Phalcon\Logger;
use Phalcon\Logger\Adapter\Stream;
use Phalcon\Logger\Exception;
use UnitTester;
use function outputFolder;

/**
* Trait SessionBagTrait
*
* @package Phalcon\Test\Fixtures\Traits
*/
trait SessionBagTrait
{
/**
* @param UnitTester $I
*/
public function _before(UnitTester $I)
{
$this->setNewFactoryDefault();
$this->setDiSession();
}

/**
* @return mixed
*/
abstract protected function setNewFactoryDefault();

/**
* @return mixed
*/
abstract protected function setDiSession();
}
7 changes: 6 additions & 1 deletion tests/integration/Session/Bag/ConstructCest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -12,7 +13,11 @@
namespace Phalcon\Test\Integration\Session\Bag;

use IntegrationTester;
use Phalcon\Session\Bag;

/**
* Class ConstructCest
*/
class ConstructCest
{
/**
Expand All @@ -26,7 +31,7 @@ class ConstructCest
public function sessionBagConstruct(IntegrationTester $I)
{
$I->wantToTest("Session\Bag - __construct()");
$session = new \Phalcon\Session\Bag("test");
$session = new Bag("test");
$I->assertInstanceOf("\Phalcon\Session\Bag", $session);
}
}
12 changes: 11 additions & 1 deletion tests/integration/Session/Bag/CountCest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -12,9 +13,18 @@
namespace Phalcon\Test\Integration\Session\Bag;

use IntegrationTester;
use Phalcon\Session\Bag;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Fixtures\Traits\SessionBagTrait;

/**
* Class CountCest
*/
class CountCest
{
use DiTrait;
use SessionBagTrait;

/**
* Tests Phalcon\Session\Bag :: count()
*
Expand All @@ -26,7 +36,7 @@ class CountCest
public function sessionBagCount(IntegrationTester $I)
{
$I->wantToTest("Session\Bag - count()");
$session = new \Phalcon\Session\Bag("CountTest");
$session = new Bag("CountTest");
$session->test1 = "test";
$session->test2 = "test";
$session->test3 = "test";
Expand Down
14 changes: 12 additions & 2 deletions tests/integration/Session/Bag/DestroyCest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -12,9 +13,18 @@
namespace Phalcon\Test\Integration\Session\Bag;

use IntegrationTester;
use Phalcon\Session\Bag;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Fixtures\Traits\SessionBagTrait;

/**
* Class DestroyCest
*/
class DestroyCest
{
use DiTrait;
use SessionBagTrait;

/**
* Tests Phalcon\Session\Bag :: destroy()
*
Expand All @@ -26,12 +36,12 @@ class DestroyCest
public function sessionBagDestroy(IntegrationTester $I)
{
$I->wantToTest("Session\Bag - destroy()");
$session = new \Phalcon\Session\Bag("DestroyTest");
$session = new Bag("DestroyTest");
// test using magic setter
$session->test = "test";
$session->destroy();

$session = new \Phalcon\Session\Bag("DestroyTest");
$session = new Bag("DestroyTest");
$I->assertEquals(null, $session->test);
}
}
12 changes: 11 additions & 1 deletion tests/integration/Session/Bag/GetCest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -12,9 +13,18 @@
namespace Phalcon\Test\Integration\Session\Bag;

use IntegrationTester;
use Phalcon\Session\Bag;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Fixtures\Traits\SessionBagTrait;

/**
* Class GetCest
*/
class GetCest
{
use DiTrait;
use SessionBagTrait;

/**
* Tests Phalcon\Session\Bag :: get()
*
Expand All @@ -26,7 +36,7 @@ class GetCest
public function sessionBagGet(IntegrationTester $I)
{
$I->wantToTest("Session\Bag - get()");
$session = new \Phalcon\Session\Bag("SetTest");
$session = new Bag("SetTest");

$testValue = "TestValue";
$session->set("test", $testValue);
Expand Down
15 changes: 13 additions & 2 deletions tests/integration/Session/Bag/GetDICest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -12,9 +13,19 @@
namespace Phalcon\Test\Integration\Session\Bag;

use IntegrationTester;
use Phalcon\Di\FactoryDefault;
use Phalcon\Session\Bag;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Fixtures\Traits\SessionBagTrait;

/**
* Class GetDICest
*/
class GetDICest
{
use DiTrait;
use SessionBagTrait;

/**
* Tests Phalcon\Session\Bag :: getDI()
*
Expand All @@ -26,8 +37,8 @@ class GetDICest
public function sessionBagGetDI(IntegrationTester $I)
{
$I->wantToTest("Session\Bag - getDI()");
$session = new \Phalcon\Session\Bag("DiTest");
$di = new \Phalcon\Di\FactoryDefault();
$session = new Bag("DiTest");
$di = new FactoryDefault();
$session->setDI($di);
$I->assertEquals($di, $session->getDI());
}
Expand Down
12 changes: 11 additions & 1 deletion tests/integration/Session/Bag/GetIteratorCest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -12,9 +13,18 @@
namespace Phalcon\Test\Integration\Session\Bag;

use IntegrationTester;
use Phalcon\Session\Bag;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Fixtures\Traits\SessionBagTrait;

/**
* Class GetIteratorCest
*/
class GetIteratorCest
{
use DiTrait;
use SessionBagTrait;

/**
* Tests Phalcon\Session\Bag :: getIterator()
*
Expand All @@ -26,7 +36,7 @@ class GetIteratorCest
public function sessionBagGetIterator(IntegrationTester $I)
{
$I->wantToTest("Session\Bag - getIterator()");
$session = new \Phalcon\Session\Bag("CountTest");
$session = new Bag("CountTest");
$session->test1 = "test";
$session->test2 = "test";
$session->test3 = "test";
Expand Down
12 changes: 11 additions & 1 deletion tests/integration/Session/Bag/HasCest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -12,9 +13,18 @@
namespace Phalcon\Test\Integration\Session\Bag;

use IntegrationTester;
use Phalcon\Session\Bag;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Fixtures\Traits\SessionBagTrait;

/**
* Class HasCest
*/
class HasCest
{
use DiTrait;
use SessionBagTrait;

/**
* Tests Phalcon\Session\Bag :: has()
*
Expand All @@ -26,7 +36,7 @@ class HasCest
public function sessionBagHas(IntegrationTester $I)
{
$I->wantToTest("Session\Bag - has()");
$session = new \Phalcon\Session\Bag("SetTest");
$session = new Bag("SetTest");

$testValue = "TestValue";
$session->set("test", $testValue);
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/Session/Bag/InitializeCest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -13,6 +14,9 @@

use IntegrationTester;

/**
* Class InitializeCest
*/
class InitializeCest
{
/**
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/Session/Bag/OffsetExistsCest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -13,6 +14,9 @@

use IntegrationTester;

/**
* Class OffsetExistsCest
*/
class OffsetExistsCest
{
/**
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/Session/Bag/OffsetGetCest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -13,6 +14,9 @@

use IntegrationTester;

/**
* Class OffsetGetCest
*/
class OffsetGetCest
{
/**
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/Session/Bag/OffsetSetCest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -13,6 +14,9 @@

use IntegrationTester;

/**
* Class OffsetSetCest
*/
class OffsetSetCest
{
/**
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/Session/Bag/OffsetUnsetCest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
Expand All @@ -13,6 +14,9 @@

use IntegrationTester;

/**
* Class OffsetUnsetCest
*/
class OffsetUnsetCest
{
/**
Expand Down

0 comments on commit e07421d

Please sign in to comment.