forked from Codeception/Codeception
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 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,24 @@ | ||
<? | ||
|
||
namespace Codeception\Module; | ||
|
||
class Kohana extends \Codeception\Util\Framework implements \Codeception\Util\FrameworkInterface { | ||
|
||
public function _initialize() { | ||
|
||
} | ||
|
||
public function _before(\Codeception\TestCase $test) { | ||
$this->client = new \Codeception\Util\Connector\Kohana(); | ||
$this->client->setIndex('public/index.php'); | ||
} | ||
|
||
public function _after(\Codeception\TestCase $test) { | ||
$_SESSION = array(); | ||
$_GET = array(); | ||
$_POST = array(); | ||
$_COOKIE = array(); | ||
parent::_after($test); | ||
} | ||
|
||
} |
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,61 @@ | ||
<?php | ||
|
||
namespace Codeception\Util\Connector; | ||
|
||
use Symfony\Component\BrowserKit\Request; | ||
use Symfony\Component\BrowserKit\Response; | ||
|
||
class Kohana extends \Symfony\Component\BrowserKit\Client { | ||
|
||
public function setIndex($index) { | ||
$this->index = $index; | ||
} | ||
|
||
public function doRequest($request) { | ||
|
||
$_COOKIE = $request->getCookies(); | ||
$_SERVER = $request->getServer(); | ||
$_FILES = $request->getFiles(); | ||
|
||
|
||
$uri = str_replace('http://localhost', '', $request->getUri()); | ||
|
||
if (strtoupper($request->getMethod()) == 'GET') { | ||
$_GET = $request->getParameters(); | ||
} | ||
if (strtoupper($request->getMethod()) == 'POST') { | ||
$_POST = $request->getParameters(); | ||
} | ||
|
||
$_SERVER['KOHANA_ENV'] = 'testing'; | ||
$_SERVER['REQUEST_METHOD'] = strtoupper($request->getMethod()); | ||
$_SERVER['REQUEST_URI'] = strtoupper($uri); | ||
|
||
$this->_initRequest(); | ||
|
||
$content = \Request::factory($uri) | ||
->execute() | ||
->send_headers() | ||
->body(); | ||
|
||
$headers = headers_list(); | ||
$headers['Content-type'] = "text/html; charset=UTF-8"; | ||
// header_remove(); | ||
$response = new Response($content, 200, $headers); | ||
return $response; | ||
} | ||
|
||
protected function _initRequest() { | ||
static $is_first_call; | ||
if ($is_first_call === Null) { | ||
$is_first_call = true; | ||
} | ||
if ($is_first_call) { | ||
$is_first_call = false; | ||
ob_start(); | ||
include $this->index; | ||
ob_end_clean(); | ||
} | ||
} | ||
|
||
} |