mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #13058 from bancer/2.x-use-trans-session-id
Add extra unit tests
This commit is contained in:
commit
8ff719de66
4 changed files with 107 additions and 2 deletions
|
@ -158,7 +158,7 @@ before_script:
|
||||||
}" > app/Config/database.php
|
}" > app/Config/database.php
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- sh -c "if [ '$PHPCS' != '1' ]; then ./lib/Cake/Console/cake test core AllTests --stderr; fi"
|
- sh -c "if [ '$PHPCS' != '1' ]; then ./lib/Cake/Console/cake test core AllTests --stderr --verbose; fi"
|
||||||
- sh -c "if [ '$PHPCS' = '1' ]; then vendors/bin/phpcs -p --extensions=php --standard=CakePHP ./lib/Cake; fi;"
|
- sh -c "if [ '$PHPCS' = '1' ]; then vendors/bin/phpcs -p --extensions=php --standard=CakePHP ./lib/Cake; fi;"
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
|
|
|
@ -41,6 +41,6 @@
|
||||||
"@test"
|
"@test"
|
||||||
],
|
],
|
||||||
"cs-check": "./vendors/bin/phpcs -p --extensions=php --standard=CakePHP ./lib/Cake",
|
"cs-check": "./vendors/bin/phpcs -p --extensions=php --standard=CakePHP ./lib/Cake",
|
||||||
"test": "./lib/Cake/Console/cake test core AllTests --stderr"
|
"test": "./lib/Cake/Console/cake test core AllTests --stderr --verbose"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ class AllControllersTest extends PHPUnit_Framework_TestSuite {
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'PagesControllerTest.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'PagesControllerTest.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'ComponentTest.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'ComponentTest.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'ControllerMergeVarsTest.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'ControllerMergeVarsTest.php');
|
||||||
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'ApplicationControllerTest.php');
|
||||||
return $suite;
|
return $suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
104
lib/Cake/Test/Case/Controller/ApplicationControllerTest.php
Normal file
104
lib/Cake/Test/Case/Controller/ApplicationControllerTest.php
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
<?php
|
||||||
|
App::uses('AppController', 'Controller');
|
||||||
|
/**
|
||||||
|
* TransSessionIdController class for testing session.use_trans_sid=1.
|
||||||
|
*
|
||||||
|
* @package Cake.Test.Case.Controller
|
||||||
|
*/
|
||||||
|
class TransSessionIdController extends AppController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param CakeRequest $request Request object for this controller.
|
||||||
|
* @param CakeResponse $response Response object for this controller.
|
||||||
|
*/
|
||||||
|
public function __construct($request = null, $response = null) {
|
||||||
|
parent::__construct($request, $response);
|
||||||
|
$ini = Configure::read('Session.ini');
|
||||||
|
$ini['session.use_cookies'] = 0;
|
||||||
|
$ini['session.use_only_cookies'] = 0;
|
||||||
|
$ini['session.use_trans_sid'] = 1;
|
||||||
|
Configure::write('Session.ini', $ini);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For testing redirect URL with session.use_trans_sid=1.
|
||||||
|
*
|
||||||
|
* @return CakeResponse|null
|
||||||
|
*/
|
||||||
|
public function next() {
|
||||||
|
$sessionName = session_name();
|
||||||
|
$sessionId = $this->Session->id();
|
||||||
|
return $this->redirect(array(
|
||||||
|
'controller' => 'trans_session_id',
|
||||||
|
'action' => 'next_step',
|
||||||
|
'?' => array(
|
||||||
|
$sessionName => $sessionId,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApplicationControllerTest class for testing controllers by using ControllerTestCase.
|
||||||
|
*
|
||||||
|
* ApplicationControllerTest extends ControllerTestCase in contrast
|
||||||
|
* with ControllerTest that extends CakeTestCase.
|
||||||
|
*
|
||||||
|
* @package Cake.Test.Case.Controller
|
||||||
|
*/
|
||||||
|
class ApplicationControllerTest extends ControllerTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setupDown method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setUp() {
|
||||||
|
CakeSession::destroy();
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tearDown method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function tearDown() {
|
||||||
|
CakeSession::destroy();
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the redirect and session config with use_trans_sid=1.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testRedirect() {
|
||||||
|
$sessionId = 'o7k64tlhil9pakp89j6d8ovlqk';
|
||||||
|
$this->testAction('/trans_session_id/next?CAKEPHP=' . $sessionId);
|
||||||
|
$this->assertContains('/trans_session_id/next_step?CAKEPHP=' . $sessionId, $this->headers['Location']);
|
||||||
|
$expectedConfig = array(
|
||||||
|
'cookie' => 'CAKEPHP',
|
||||||
|
'timeout' => 240,
|
||||||
|
'ini' => array(
|
||||||
|
'session.use_trans_sid' => 1,
|
||||||
|
'session.cookie_path' => '/',
|
||||||
|
'session.cookie_lifetime' => 14400,
|
||||||
|
'session.name' => 'CAKEPHP',
|
||||||
|
'session.gc_maxlifetime' => 14400,
|
||||||
|
'session.cookie_httponly' => 1,
|
||||||
|
'session.use_cookies' => 0,
|
||||||
|
'session.use_only_cookies' => 0,
|
||||||
|
),
|
||||||
|
'defaults' => 'php',
|
||||||
|
'cookieTimeout' => 240,
|
||||||
|
'cacheLimiter' => 'must-revalidate',
|
||||||
|
);
|
||||||
|
$actualConfig = Configure::read('Session');
|
||||||
|
$this->assertEquals($expectedConfig, $actualConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue