Skip to content

Commit

Permalink
dummy me
Browse files Browse the repository at this point in the history
  • Loading branch information
nike-17 committed Mar 15, 2012
1 parent 557b04a commit d97c61c
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Codeception/Module/Kohana.php
@@ -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);
}

}
61 changes: 61 additions & 0 deletions src/Codeception/Util/Connector/Kohana.php
@@ -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();
}
}

}

0 comments on commit d97c61c

Please sign in to comment.