Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T12921 remove session from di factory #13667

Merged
merged 6 commits into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
- Scope SQL Column Aliases (on nesting level), in `Phalcon\Mvc\Model\Query`, to prevent overwrite _root_ query's `_sqlColumnAliases` by sub-queries. [#13006](https://github.com/phalcon/cphalcon/issues/13006), [#12548](https://github.com/phalcon/cphalcon/issues/12548) and [#1731](https://github.com/phalcon/cphalcon/issues/1731)
- CLI parameters now work like MVC parameters [#12375](https://github.com/phalcon/cphalcon/pull/12375)
- Changed `Phalcon\Db\Dialect\Postgresql::addPrimaryKey` to make primary key contraints names unique by prefixing them with the table name. [#12629](https://github.com/phalcon/cphalcon/pull/12629)
- Changed `Phalcon\DI\FactoryDefault` to not load the `Phalcon\Session\Adapter\Files` using the name `session` by default [#12921](https://github.com/phalcon/cphalcon/issues/12921)
sergeyklay marked this conversation as resolved.
Show resolved Hide resolved

## Removed
- PHP < 7.2 no longer supported
Expand Down
26 changes: 12 additions & 14 deletions phalcon/di/factorydefault.zep
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,25 @@ class FactoryDefault extends \Phalcon\Di
parent::__construct();

let this->_services = [
"router": new Service("Phalcon\\Mvc\\Router", true),
"annotations": new Service("Phalcon\\Annotations\\Adapter\\Memory", 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),
"url": new Service("Phalcon\\Mvc\\Url", true),
"escaper": new Service("Phalcon\\Escaper", true),
"eventsManager": new Service("Phalcon\\Events\\Manager", true),
"flash": new Service("Phalcon\\Flash\\Direct", true),
"flashSession": new Service("Phalcon\\Flash\\Session", true),
"filter": new Service("Phalcon\\Filter", true),
"modelsManager": new Service("Phalcon\\Mvc\\Model\\Manager", true),
"modelsMetadata": new Service("Phalcon\\Mvc\\Model\\MetaData\\Memory", true),
"response": new Service("Phalcon\\Http\\Response", true),
"cookies": new Service("Phalcon\\Http\\Response\\Cookies", true),
"request": new Service("Phalcon\\Http\\Request", true),
"filter": new Service("Phalcon\\Filter", true),
"escaper": new Service("Phalcon\\Escaper", true),
"response": new Service("Phalcon\\Http\\Response", true),
"router": new Service("Phalcon\\Mvc\\Router", true),
"security": new Service("Phalcon\\Security", true),
"crypt": new Service("Phalcon\\Crypt", true),
"annotations": new Service("Phalcon\\Annotations\\Adapter\\Memory", true),
"flash": new Service("Phalcon\\Flash\\Direct", true),
"flashSession": new Service("Phalcon\\Flash\\Session", true),
"tag": new Service("Phalcon\\Tag", true),
"session": new Service("Phalcon\\Session\\Adapter\\Files", true),
"sessionBag": new Service("Phalcon\\Session\\Bag"),
"eventsManager": new Service("Phalcon\\Events\\Manager", true),
"transactionManager": new Service("Phalcon\\Mvc\\Model\\Transaction\\Manager", true),
"assets": new Service("Phalcon\\Assets\\Manager", true)
"url": new Service("Phalcon\\Mvc\\Url", true)
];
}
}
10 changes: 5 additions & 5 deletions phalcon/di/factorydefault/cli.zep
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ class Cli extends FactoryDefault
parent::__construct();

let this->_services = [
"router": new Service("Phalcon\\Cli\\Router", true),
"annotations": new Service("Phalcon\\Annotations\\Adapter\\Memory", true),
"dispatcher": new Service("Phalcon\\Cli\\Dispatcher", true),
"escaper": new Service("Phalcon\\Escaper", true),
"eventsManager": new Service("Phalcon\\Events\\Manager", true),
"filter": new Service("Phalcon\\Filter", true),
"modelsManager": new Service("Phalcon\\Mvc\\Model\\Manager", true),
"modelsMetadata": new Service("Phalcon\\Mvc\\Model\\MetaData\\Memory", true),
"filter": new Service("Phalcon\\Filter", true),
"escaper": new Service("Phalcon\\Escaper", true),
"annotations": new Service("Phalcon\\Annotations\\Adapter\\Memory", true),
"router": new Service("Phalcon\\Cli\\Router", true),
"security": new Service("Phalcon\\Security", true),
"eventsManager": new Service("Phalcon\\Events\\Manager", true),
"transactionManager": new Service("Phalcon\\Mvc\\Model\\Transaction\\Manager", true)
];
}
Expand Down
46 changes: 46 additions & 0 deletions tests/_data/fixtures/Traits/SessionBagTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <[email protected]>
*
* 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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading