Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on the cookie implementation tests
- Loading branch information
Florian Krämer
committed
Feb 15, 2017
1 parent
de41228
commit d571324
Showing
4 changed files
with
98 additions
and
7 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,68 @@ | ||
<?php | ||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @since 3.5.0 | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
namespace Cake\Test\TestCase\Http\Cookie; | ||
|
||
use Cake\Http\Cookie\Cookie; | ||
use Cake\Http\Cookie\CookieCollection; | ||
use Cake\TestSuite\TestCase; | ||
|
||
/** | ||
* Cookie collection test. | ||
*/ | ||
class CookieCollectionTest extends TestCase | ||
{ | ||
/** | ||
* Test constructor | ||
* | ||
* @return void | ||
*/ | ||
public function testConstructorWithEmptyArray() | ||
{ | ||
$collection = new CookieCollection([]); | ||
$this->assertCount(0, $collection); | ||
} | ||
|
||
/** | ||
* Test valid cookies | ||
* | ||
* @return void | ||
*/ | ||
public function testConstructorWithCookieArray() | ||
{ | ||
$cookies = [ | ||
new Cookie('one', 'one'), | ||
new Cookie('two', 'two') | ||
]; | ||
|
||
$collection = new CookieCollection($cookies); | ||
$this->assertCount(2, $collection); | ||
} | ||
|
||
/** | ||
* Test that the constructor takes only an array of objects implementing | ||
* the CookieInterface | ||
* | ||
* @expectedException \InvalidArgumentException | ||
* @expectedExceptionMessage Expected `Cake\Http\Cookie\CookieCollection[]` as $cookies but instead got `array` at index 1 | ||
* @return void | ||
*/ | ||
public function testConstructorWithInvalidCookieObjects() | ||
{ | ||
$array = [ | ||
new Cookie('one', 'one'), | ||
[] | ||
]; | ||
|
||
new CookieCollection($array); | ||
} | ||
} |
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