Skip to content

Commit

Permalink
[#14627] - Added more cookie tets
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed Jan 5, 2020
1 parent 8a3d4c4 commit 7ef460a
Show file tree
Hide file tree
Showing 24 changed files with 537 additions and 413 deletions.
31 changes: 0 additions & 31 deletions tests/cli/Cli/Dispatcher/SetActionNameCest.php

This file was deleted.

31 changes: 0 additions & 31 deletions tests/cli/Cli/Dispatcher/SetHandlerSuffixCest.php

This file was deleted.

34 changes: 0 additions & 34 deletions tests/cli/Cli/Dispatcher/SetTaskNameCest.php

This file was deleted.

31 changes: 0 additions & 31 deletions tests/cli/Cli/Dispatcher/SetTaskSuffixCest.php

This file was deleted.

11 changes: 10 additions & 1 deletion tests/unit/Http/Cookie/ConstructCest.php
Expand Up @@ -13,10 +13,14 @@

namespace Phalcon\Test\Unit\Http\Cookie;

use Phalcon\Http\Cookie;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use UnitTester;

class ConstructCest
{
use DiTrait;

/**
* Tests Phalcon\Http\Cookie :: __construct()
*
Expand All @@ -27,6 +31,11 @@ public function httpCookieConstruct(UnitTester $I)
{
$I->wantToTest('Http\Cookie - __construct()');

$I->skipTest('Need implementation');
$this->setNewFactoryDefault();
$this->setDiSessionFiles();

$cookie = new Cookie('test');
$I->assertInstanceOf(Cookie\CookieInterface::class, $cookie);
$I->assertInstanceOf(Cookie::class, $cookie);
}
}
28 changes: 26 additions & 2 deletions tests/unit/Http/Cookie/GetNameCest.php
Expand Up @@ -14,10 +14,13 @@
namespace Phalcon\Test\Unit\Http\Cookie;

use Phalcon\Http\Cookie;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use UnitTester;

class GetNameCest
{
use DiTrait;

/**
* Tests Phalcon\Http\Cookie :: getName()
*
Expand All @@ -28,8 +31,29 @@ public function httpCookieGetName(UnitTester $I)
{
$I->wantToTest('Http\Cookie - getName()');

$cookie = new Cookie('test-cookie');
$this->setNewFactoryDefault();

$name = 'test';
$value = "phalcon";
$expire = time() - 100;
$path = "/";
$secure = true;
$domain = "phalcon.ld";
$httpOnly = true;
$options = ["samesite" => "Lax"];

$cookie = new Cookie(
$name,
$value,
$expire,
$path,
$secure,
$domain,
$httpOnly,
$options
);
$cookie->setDI($this->container);

$I->assertEquals('test-cookie', $cookie->getName());
$I->assertEquals($name, $cookie->getName());
}
}
32 changes: 0 additions & 32 deletions tests/unit/Http/Cookie/GetPathCest.php

This file was deleted.

32 changes: 0 additions & 32 deletions tests/unit/Http/Cookie/GetSecureCest.php

This file was deleted.

44 changes: 31 additions & 13 deletions tests/unit/Http/Cookie/GetSetDomainCest.php
Expand Up @@ -14,33 +14,51 @@
namespace Phalcon\Test\Unit\Http\Cookie;

use Phalcon\Http\Cookie;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use UnitTester;

class GetSetDomainCest
{
use DiTrait;

/**
* Tests Phalcon\Http\Cookie :: getDomain() / setDomain()
* Tests Phalcon\Http\Cookie :: getDomain()/setDomain()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
*/
public function httpCookieGetDomain(UnitTester $I)
public function httpCookieGetSetDomain(UnitTester $I)
{
$I->wantToTest('Http\Cookie - getDomain() / setDomain()');
$I->wantToTest('Http\Cookie - getDomain()/setDomain()');

$this->setNewFactoryDefault();
$this->setDiSessionFiles();

$name = 'test';
$value = "phalcon";
$expire = time() - 100;
$path = "/";
$secure = true;
$domain = "phalcon.ld";
$httpOnly = true;
$options = ["samesite" => "Lax"];

$cookie = new Cookie(
'test-cookie',
'test',
time() + 3600,
'/',
null,
'phalcon.ltd'
$name,
$value,
$expire,
$path,
$secure,
$domain,
$httpOnly,
$options
);
$cookie->setDI($this->container);

$I->assertEquals('phalcon.ltd', $cookie->getDomain());

$cookie->setDomain('phalcon.io');
$I->assertEquals($domain, $cookie->getDomain());

$I->assertEquals('phalcon.io', $cookie->getDomain());
$domain = 'phalcon.io';
$cookie->setDomain($domain);
$I->assertEquals($domain, $cookie->getDomain());
}
}

0 comments on commit 7ef460a

Please sign in to comment.