Kohana v3.3.2

This commit is contained in:
Deon George
2014-09-06 23:43:07 +10:00
parent f96694b18f
commit 8888719653
236 changed files with 1685 additions and 996 deletions

View File

@@ -481,6 +481,8 @@ class Kohana_ArrTest extends Unittest_TestCase
array(array('kohana' => array('is' => 'awesome')), array(), 'kohana/is', 'awesome', '/'),
// Ensures set_path() casts ints to actual integers for keys
array(array('foo' => array('bar')), array('foo' => array('test')), 'foo.0', 'bar'),
// Tests if it allows arrays
array(array('kohana' => array('is' => 'awesome')), array(), array('kohana', 'is'), 'awesome'),
);
}

View File

@@ -10,8 +10,8 @@
* @author Kohana Team
* @author Jeremy Bush <contractfrombelow@gmail.com>
* @author Matt Button <matthew@sigswitch.com>
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Config_File_ReaderTest extends Kohana_Unittest_TestCase {

View File

@@ -10,8 +10,8 @@
* @author Kohana Team
* @author Jeremy Bush <contractfrombelow@gmail.com>
* @author Matt Button <matthew@sigswitch.com>
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Config_GroupTest extends Kohana_Unittest_TestCase
{

View File

@@ -107,11 +107,33 @@ class Kohana_CoreTest extends Unittest_TestCase
*/
public function test_globals_removes_user_def_globals()
{
// Store the globals
$temp_globals = array(
'cookie' => $_COOKIE,
'get' => $_GET,
'files' => $_FILES,
'post' => $_POST,
'request' => $_REQUEST,
'server' => $_SERVER,
'session' => $_SESSION,
'globals' => $GLOBALS,
);
$GLOBALS = array('hackers' => 'foobar','name' => array('','',''), '_POST' => array());
Kohana::globals();
$this->assertEquals(array('_POST' => array()), $GLOBALS);
// Reset the globals for other tests
$_COOKIE = $temp_globals['cookie'];
$_GET = $temp_globals['get'];
$_FILES = $temp_globals['files'];
$_POST = $temp_globals['post'];
$_REQUEST = $temp_globals['request'];
$_SERVER = $temp_globals['server'];
$_SESSION = $temp_globals['session'];
$GLOBALS = $temp_globals['globals'];
}
/**

View File

@@ -13,8 +13,8 @@
* @category Tests
* @author Kohana Team
* @author Jeremy Bush <contractfrombelow@gmail.com>
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_DebugTest extends Unittest_TestCase
{

View File

@@ -11,8 +11,8 @@
* @package Kohana
* @category Tests
* @author Kohana Team
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_HTTP_HeaderTest extends Unittest_TestCase {

View File

@@ -361,34 +361,6 @@ class Kohana_RouteTest extends Unittest_TestCase
),
'',
),
/**
* Specifying this should cause controller and action to show up
* refs #4113
*/
array(
'(<controller>(/<action>(/<id>)))',
NULL,
array('controller' => 'welcome', 'action' => 'index'),
'Welcome',
'index',
'welcome/index/1',
array(
'id' => '1'
),
'',
),
array(
'<controller>(/<action>(/<id>))',
NULL,
array('controller' => 'welcome', 'action' => 'index'),
'Welcome',
'index',
'welcome/foo',
array(
'action' => 'foo',
),
'welcome',
),
);
}
@@ -427,6 +399,107 @@ class Kohana_RouteTest extends Unittest_TestCase
$this->assertSame($default_uri, $route->uri());
}
/**
* Provider for test_optional_groups_containing_specified_params
*
* @return array
*/
public function provider_optional_groups_containing_specified_params()
{
return array(
/**
* Specifying this should cause controller and action to show up
* refs #4113
*/
array(
'(<controller>(/<action>(/<id>)))',
array('controller' => 'welcome', 'action' => 'index'),
array('id' => '1'),
'welcome/index/1',
),
array(
'<controller>(/<action>(/<id>))',
array('controller' => 'welcome', 'action' => 'index'),
array('action' => 'foo'),
'welcome/foo',
),
array(
'<controller>(/<action>(/<id>))',
array('controller' => 'welcome', 'action' => 'index'),
array('action' => 'index'),
'welcome',
),
/**
* refs #4630
*/
array(
'api(/<version>)/const(/<id>)(/<custom>)',
array('version' => 1),
NULL,
'api/const',
),
array(
'api(/<version>)/const(/<id>)(/<custom>)',
array('version' => 1),
array('version' => 9),
'api/9/const',
),
array(
'api(/<version>)/const(/<id>)(/<custom>)',
array('version' => 1),
array('id' => 2),
'api/const/2',
),
array(
'api(/<version>)/const(/<id>)(/<custom>)',
array('version' => 1),
array('custom' => 'x'),
'api/const/x',
),
array(
'(<controller>(/<action>(/<id>)(/<type>)))',
array('controller' => 'test', 'action' => 'index', 'type' => 'html'),
array('type' => 'json'),
'test/index/json',
),
array(
'(<controller>(/<action>(/<id>)(/<type>)))',
array('controller' => 'test', 'action' => 'index', 'type' => 'html'),
array('id' => 123),
'test/index/123',
),
array(
'(<controller>(/<action>(/<id>)(/<type>)))',
array('controller' => 'test', 'action' => 'index', 'type' => 'html'),
array('id' => 123, 'type' => 'html'),
'test/index/123',
),
array(
'(<controller>(/<action>(/<id>)(/<type>)))',
array('controller' => 'test', 'action' => 'index', 'type' => 'html'),
array('id' => 123, 'type' => 'json'),
'test/index/123/json',
),
);
}
/**
* When an optional param is specified, the optional params leading up to it
* must be in the URI.
*
* @dataProvider provider_optional_groups_containing_specified_params
*
* @ticket 4113
* @ticket 4630
*/
public function test_optional_groups_containing_specified_params($uri, $defaults, $params, $expected)
{
$route = new Route($uri, NULL);
$route->defaults($defaults);
$this->assertSame($expected, $route->uri($params));
}
/**
* Optional params should not be used if what is passed in is identical
* to the default.
@@ -556,6 +629,15 @@ class Kohana_RouteTest extends Unittest_TestCase
NULL,
array('action' => 'awesome-action'),
),
/**
* Optional params are required when they lead to a specified param
* refs #4113
*/
array(
'(<controller>(/<action>))',
NULL,
array('action' => 'awesome-action'),
),
);
}
@@ -573,18 +655,8 @@ class Kohana_RouteTest extends Unittest_TestCase
{
$route = new Route($uri, $regex);
try
{
$route->uri($uri_array);
$this->fail('Route::uri should throw exception if required param is not provided');
}
catch(Exception $e)
{
$this->assertInstanceOf('Kohana_Exception', $e);
// Check that the error in question is about the controller param
$this->assertContains('controller', $e->getMessage());
}
$this->setExpectedException('Kohana_Exception', 'controller');
$route->uri($uri_array);
}
/**

View File

@@ -858,6 +858,15 @@ class Kohana_ValidTest extends Unittest_TestCase
// #4043
array(2, 0, 10, 2, TRUE),
array(3, 0, 10, 2, FALSE),
// #4672
array(0, 0, 10, NULL, TRUE),
array(10, 0, 10, NULL, TRUE),
array(-10, -10, 10, NULL, TRUE),
array(-10, -1, 1, NULL, FALSE),
array(0, 0, 10, 2, TRUE), // with $step
array(10, 0, 10, 2, TRUE),
array(10, 0, 10, 3, FALSE), // max outside $step
array(12, 0, 12, 3, TRUE),
// Empty test
array('', 5, 10, NULL, FALSE),
array(NULL, 5, 10, NULL, FALSE),

View File

@@ -175,6 +175,29 @@ class Kohana_Request_ClientTest extends Unittest_TestCase
$this->assertFalse(isset($headers['x-not-in-follow']), 'X-Not-In-Follow should not be passed to next request');
}
/**
* Tests that the follow_headers are only added to a redirect request if they were present in the original
*
* @ticket 4790
*/
public function test_follow_does_not_add_extra_headers()
{
$response = Request::factory(
$this->_dummy_redirect_uri(301),
array(
'follow' => TRUE,
'follow_headers' => array('Authorization')
))
->headers(array())
->execute();
$data = json_decode($response->body(),TRUE);
$headers = $data['rq_headers'];
$this->assertArrayNotHasKey('authorization', $headers, 'Empty headers should not be added when following redirects');
}
/**
* Provider for test_follows_with_strict_method
*

View File

@@ -148,7 +148,7 @@ class Kohana_Request_Client_ExternalTest extends Unittest_TestCase {
$json,
$post,
array(
'content-type' => 'application/x-www-form-urlencoded',
'content-type' => 'application/x-www-form-urlencoded; charset='.Kohana::$charset,
'body' => http_build_query($post, NULL, '&')
)
)