Update Kohana to 3.1.3.1
This commit is contained in:
@@ -2,15 +2,15 @@
|
||||
/**
|
||||
* PHPUnit Kohana web based test runner
|
||||
*
|
||||
* @package Kohana/Unittest
|
||||
* @package Kohana/UnitTest
|
||||
* @author Kohana Team
|
||||
* @author BRMatt <matthew@sigswitch.com>
|
||||
* @author Paul Banks
|
||||
* @author Paul Banks
|
||||
* @copyright (c) 2008-2009 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
*/
|
||||
|
||||
Class Controller_UnitTest extends Controller_Template
|
||||
class Controller_UnitTest extends Controller_Template
|
||||
{
|
||||
/**
|
||||
* Whether the archive module is available
|
||||
@@ -20,7 +20,7 @@ Class Controller_UnitTest extends Controller_Template
|
||||
|
||||
/**
|
||||
* Unittest config
|
||||
* @var Kohana_Config
|
||||
* @var Config
|
||||
*/
|
||||
protected $config = NULL;
|
||||
|
||||
@@ -55,28 +55,28 @@ Class Controller_UnitTest extends Controller_Template
|
||||
{
|
||||
parent::before();
|
||||
|
||||
if ( ! Kohana_Tests::enabled())
|
||||
if ( ! Unittest_tests::enabled())
|
||||
{
|
||||
// Pretend this is a normal 404 error...
|
||||
$this->status = 404;
|
||||
|
||||
throw new Kohana_Request_Exception('Unable to find a route to match the URI: :uri',
|
||||
array(':uri' => $this->request->uri));
|
||||
array(':uri' => $this->request->uri()));
|
||||
}
|
||||
|
||||
// Prevent the whitelist from being autoloaded, but allow the blacklist
|
||||
// to be loaded
|
||||
Kohana_Tests::configure_environment(FALSE);
|
||||
Unittest_Tests::configure_environment(FALSE);
|
||||
|
||||
$this->config = Kohana::config('unittest');
|
||||
|
||||
// This just stops some very very long lines
|
||||
$route = Route::get('unittest');
|
||||
$this->report_uri = $route->uri(array('action' => 'report'));
|
||||
$this->run_uri = $route->uri(array('action' => 'run'));
|
||||
$this->run_uri = $route->uri(array('action' => 'run'));
|
||||
|
||||
// Switch used to disable cc settings
|
||||
$this->xdebug_loaded = extension_loaded('xdebug');
|
||||
$this->xdebug_loaded = extension_loaded('xdebug');
|
||||
$this->cc_archive_enabled = class_exists('Archive');
|
||||
|
||||
Kohana_View::set_global('xdebug_enabled', $this->xdebug_loaded);
|
||||
@@ -92,7 +92,7 @@ Class Controller_UnitTest extends Controller_Template
|
||||
->set('run_uri', $this->run_uri)
|
||||
->set('report_uri', $this->report_uri)
|
||||
->set('whitelistable_items', $this->get_whitelistable_items())
|
||||
->set('groups', $this->get_groups_list(Kohana_Tests::suite()));
|
||||
->set('groups', $this->get_groups_list(Unittest_tests::suite()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,16 +102,14 @@ Class Controller_UnitTest extends Controller_Template
|
||||
{
|
||||
// Fairly foolproof
|
||||
if ( ! $this->config->cc_report_path AND ! class_exists('Archive'))
|
||||
{
|
||||
throw new Kohana_Exception('Cannot generate report');
|
||||
}
|
||||
|
||||
// We don't want to use the HTML layout, we're sending the user 100111011100110010101100
|
||||
$this->auto_render = FALSE;
|
||||
|
||||
$suite = Kohana_Tests::suite();
|
||||
$suite = Unittest_tests::suite();
|
||||
$temp_path = rtrim($this->config->temp_path, '/').'/';
|
||||
$group = (array) Arr::get($_GET, 'group', array());
|
||||
$group = (array) Arr::get($_GET, 'group', array());
|
||||
|
||||
// Stop unittest from interpretting "all groups" as "no groups"
|
||||
if (empty($group) OR empty($group[0]))
|
||||
@@ -150,21 +148,17 @@ Class Controller_UnitTest extends Controller_Template
|
||||
else
|
||||
{
|
||||
$folder = trim($this->config->cc_report_path, '/').'/';
|
||||
$path = DOCROOT.$folder;
|
||||
$path = DOCROOT.$folder;
|
||||
|
||||
if ( ! file_exists($path))
|
||||
{
|
||||
throw new Kohana_Exception('Report directory :dir does not exist', array(':dir' => $path));
|
||||
}
|
||||
|
||||
if ( ! is_writable($path))
|
||||
{
|
||||
throw new Kohana_Exception('Script doesn\'t have permission to write to report dir :dir ', array(':dir' => $path));
|
||||
}
|
||||
|
||||
$runner->generate_report($group, $path, FALSE);
|
||||
|
||||
$this->request->redirect(URL::base(FALSE, TRUE).$folder.'index.html');
|
||||
$this->request->redirect(URL::site($folder.'index.html', $this->request));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +170,7 @@ Class Controller_UnitTest extends Controller_Template
|
||||
$this->template->body = View::factory('unittest/results');
|
||||
|
||||
// Get the test suite and work out which groups we're testing
|
||||
$suite = Kohana_Tests::suite();
|
||||
$suite = Unittest_tests::suite();
|
||||
$group = (array) Arr::get($_GET, 'group', array());
|
||||
|
||||
|
||||
@@ -220,19 +214,20 @@ Class Controller_UnitTest extends Controller_Template
|
||||
// Show some results
|
||||
$this->template->body
|
||||
->set('results', $runner->results)
|
||||
->set('totals', $runner->totals)
|
||||
->set('time', $this->nice_time($runner->time))
|
||||
->set('totals', $runner->totals)
|
||||
->set('time', $this->nice_time($runner->time))
|
||||
|
||||
// Sets group to the currently selected group, or default all groups
|
||||
->set('group', Arr::get($this->get_groups_list($suite), reset($group), 'All groups'))
|
||||
->set('group', Arr::get($this->get_groups_list($suite), reset($group), 'All groups'))
|
||||
->set('groups', $this->get_groups_list($suite))
|
||||
|
||||
->set('report_uri', $this->report_uri.url::query())
|
||||
->set('run_uri', $this->request->uri())
|
||||
->set('report_uri', $this->report_uri.url::query())
|
||||
|
||||
// Whitelist related stuff
|
||||
->set('whitelistable_items', $this->get_whitelistable_items())
|
||||
->set('whitelisted_items', isset($whitelist) ? array_keys($whitelist) : array())
|
||||
->set('whitelist', ! empty($whitelist));
|
||||
->set('whitelisted_items', isset($whitelist) ? array_keys($whitelist) : array())
|
||||
->set('whitelist', ! empty($whitelist));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,9 +257,7 @@ Class Controller_UnitTest extends Controller_Template
|
||||
static $whitelist;
|
||||
|
||||
if (count($whitelist))
|
||||
{
|
||||
return $whitelist;
|
||||
}
|
||||
|
||||
$whitelist = array();
|
||||
|
||||
@@ -308,7 +301,7 @@ Class Controller_UnitTest extends Controller_Template
|
||||
|
||||
if (count($whitelist))
|
||||
{
|
||||
Kohana_Tests::whitelist($whitelist);
|
||||
Unittest_tests::whitelist($whitelist);
|
||||
}
|
||||
|
||||
return $whitelist;
|
||||
|
@@ -2,13 +2,14 @@
|
||||
/**
|
||||
* TestCase for testing a database
|
||||
*
|
||||
* @package Kohana/Unittest
|
||||
* @package Kohana/UnitTest
|
||||
* @author Kohana Team
|
||||
* @author BRMatt <matthew@sigswitch.com>
|
||||
* @copyright (c) 2008-2009 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
*/
|
||||
Abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Database_TestCase {
|
||||
// @codingStandardsIgnoreFile
|
||||
abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Database_TestCase {
|
||||
|
||||
/**
|
||||
* Whether we should enable work arounds to make the tests compatible with phpunit 3.4
|
||||
@@ -43,8 +44,13 @@ Abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Data
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
if(self::$_assert_type_compatability === NULL)
|
||||
if (self::$_assert_type_compatability === NULL)
|
||||
{
|
||||
if ( ! class_exists('PHPUnit_Runner_Version'))
|
||||
{
|
||||
require_once 'PHPUnit/Runner/Version.php';
|
||||
}
|
||||
|
||||
self::$_assert_type_compatability = version_compare(PHPUnit_Runner_Version::id(), '3.5.0', '<=');
|
||||
}
|
||||
|
||||
@@ -95,15 +101,15 @@ Abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Data
|
||||
return $this->createDefaultDBConnection($pdo, $config['connection']['database']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a connection to the unittest database
|
||||
*
|
||||
* @return Kohana_Database The database connection
|
||||
*/
|
||||
public function getKohanaConnection()
|
||||
{
|
||||
return Database::instance(Kohana::config('unittest')->db_connection);
|
||||
}
|
||||
/**
|
||||
* Gets a connection to the unittest database
|
||||
*
|
||||
* @return Kohana_Database The database connection
|
||||
*/
|
||||
public function getKohanaConnection()
|
||||
{
|
||||
return Database::instance(Kohana::config('unittest')->db_connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all kohana related cache files in the cache directory
|
||||
@@ -161,10 +167,8 @@ Abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Data
|
||||
*/
|
||||
public static function assertInstanceOf($expected, $actual, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertType($expected, $actual, $message);
|
||||
}
|
||||
|
||||
return parent::assertInstanceOf($expected, $actual, $message);
|
||||
}
|
||||
@@ -180,10 +184,8 @@ Abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Data
|
||||
*/
|
||||
public static function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertAttributeType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
|
||||
return parent::assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
@@ -198,10 +200,8 @@ Abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Data
|
||||
*/
|
||||
public static function assertNotInstanceOf($expected, $actual, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertNotType($expected, $actual, $message);
|
||||
}
|
||||
|
||||
return self::assertNotInstanceOf($expected, $actual, $message);
|
||||
}
|
||||
@@ -217,10 +217,8 @@ Abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Data
|
||||
*/
|
||||
public static function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertAttributeNotType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
|
||||
return self::assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
@@ -235,10 +233,8 @@ Abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Data
|
||||
*/
|
||||
public static function assertInternalType($expected, $actual, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertType($expected, $actual, $message);
|
||||
}
|
||||
|
||||
return parent::assertInternalType($expected, $actual, $message);
|
||||
}
|
||||
@@ -254,10 +250,8 @@ Abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Data
|
||||
*/
|
||||
public static function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertAttributeType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
|
||||
return self::assertAttributeInternalType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
@@ -272,10 +266,8 @@ Abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Data
|
||||
*/
|
||||
public static function assertNotInternalType($expected, $actual, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertNotType($expected, $actual, $message);
|
||||
}
|
||||
|
||||
return self::assertNotInternalType($expected, $actual, $message);
|
||||
}
|
||||
@@ -291,10 +283,8 @@ Abstract Class Kohana_Unittest_Database_TestCase extends PHPUnit_Extensions_Data
|
||||
*/
|
||||
public static function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertAttributeNotType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
|
||||
return self::assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
|
@@ -1,16 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Unit testing helpers
|
||||
*
|
||||
* @package Kohana/Unittest
|
||||
* @author Kohana Team
|
||||
* @author BRMatt <matthew@sigswitch.com>
|
||||
* @author Paul Banks
|
||||
* @copyright (c) 2008-2009 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
*/
|
||||
class Kohana_Unittest_Helpers
|
||||
{
|
||||
class Kohana_Unittest_Helpers {
|
||||
/**
|
||||
* Static variable used to work out whether we have an internet
|
||||
* connection
|
||||
@@ -139,7 +132,7 @@ class Kohana_Unittest_Helpers
|
||||
$class->setStaticPropertyValue($var, $value);
|
||||
}
|
||||
// If this is an environment variable
|
||||
elseif (preg_match('/^[A-Z_-]+$/', $option) OR isset($_SERVER[$option]))
|
||||
elseif (preg_match('/^[A-Z_-]+$/D', $option) OR isset($_SERVER[$option]))
|
||||
{
|
||||
if ($backup_needed)
|
||||
{
|
||||
|
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPUnit test runner for kohana
|
||||
*
|
||||
* @package Kohana/Unittest
|
||||
* @package Kohana/UnitTest
|
||||
* @author Kohana Team
|
||||
* @author BRMatt <matthew@sigswitch.com>
|
||||
* @author Paul Banks
|
||||
* @copyright (c) 2008-2009 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
*/
|
||||
Class Kohana_Unittest_Runner implements PHPUnit_Framework_TestListener
|
||||
{
|
||||
class Kohana_Unittest_Runner implements PHPUnit_Framework_TestListener {
|
||||
/**
|
||||
* Results
|
||||
* @var array
|
||||
@@ -160,9 +160,7 @@ Class Kohana_Unittest_Runner implements PHPUnit_Framework_TestListener
|
||||
public function generate_report(array $groups, $temp_path, $create_sub_dir = TRUE)
|
||||
{
|
||||
if ( ! is_writable($temp_path))
|
||||
{
|
||||
throw new Kohana_Exception('Temp path :path does not exist or is not writable by the webserver', array(':path' => $temp_path));
|
||||
}
|
||||
|
||||
$folder_path = $temp_path;
|
||||
|
||||
@@ -209,9 +207,7 @@ Class Kohana_Unittest_Runner implements PHPUnit_Framework_TestListener
|
||||
public function run(array $groups = array(), $collect_cc = FALSE)
|
||||
{
|
||||
if ($collect_cc AND ! extension_loaded('xdebug'))
|
||||
{
|
||||
throw new Kohana_Exception('Code coverage cannot be collected because the xdebug extension is not loaded');
|
||||
}
|
||||
|
||||
$this->result->collectCodeCoverageInformation( (bool) $collect_cc);
|
||||
|
||||
@@ -221,43 +217,54 @@ Class Kohana_Unittest_Runner implements PHPUnit_Framework_TestListener
|
||||
return $this;
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
|
||||
// @codingStandardsIgnoreEnd
|
||||
{
|
||||
$this->totals['errors']++;
|
||||
$this->current['result'] = 'errors';
|
||||
$this->current['message'] = $test->getStatusMessage();
|
||||
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
|
||||
// @codingStandardsIgnoreEnd
|
||||
{
|
||||
$this->totals['failures']++;
|
||||
$this->current['result'] = 'failures';
|
||||
$this->current['message'] = $test->getStatusMessage();
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
|
||||
// @codingStandardsIgnoreEnd
|
||||
{
|
||||
$this->totals['incomplete']++;
|
||||
$this->current['result'] = 'incomplete';
|
||||
$this->current['message'] = $test->getStatusMessage();
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
|
||||
// @codingStandardsIgnoreEnd
|
||||
{
|
||||
$this->totals['skipped']++;
|
||||
$this->current['result'] = 'skipped';
|
||||
$this->current['message'] = $test->getStatusMessage();
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
public function startTest(PHPUnit_Framework_Test $test)
|
||||
// @codingStandardsIgnoreEnd
|
||||
{
|
||||
$this->current['name'] = $test->getName(FALSE);
|
||||
$this->current['description'] = $test->toString();
|
||||
$this->current['result'] = 'passed';
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
public function endTest(PHPUnit_Framework_Test $test, $time)
|
||||
// @codingStandardsIgnoreEnd
|
||||
{
|
||||
// Add totals
|
||||
$this->totals['tests']++;
|
||||
@@ -280,11 +287,13 @@ Class Kohana_Unittest_Runner implements PHPUnit_Framework_TestListener
|
||||
$this->time += $time;
|
||||
}
|
||||
|
||||
public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
|
||||
{
|
||||
}
|
||||
// @codingStandardsIgnoreStart
|
||||
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
|
||||
// @codingStandardsIgnoreEnd
|
||||
{
|
||||
// Parse test descriptions to make them look nicer
|
||||
foreach ($this->results as $case => $testresults)
|
||||
|
@@ -1,14 +1,10 @@
|
||||
<?php
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* TestCase for unittesting
|
||||
*
|
||||
* @package Kohana/Unittest
|
||||
* @author Kohana Team
|
||||
* @author BRMatt <matthew@sigswitch.com>
|
||||
* @author Paul Banks
|
||||
* @copyright (c) 2008-2009 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
* A version of the stock PHPUnit testcase that includes some extra helpers
|
||||
* and default settings
|
||||
*/
|
||||
// @codingStandardsIgnoreFile
|
||||
abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
@@ -44,12 +40,17 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
if(self::$_assert_type_compatability === NULL)
|
||||
if (self::$_assert_type_compatability === NULL)
|
||||
{
|
||||
if ( ! class_exists('PHPUnit_Runner_Version'))
|
||||
{
|
||||
require_once 'PHPUnit/Runner/Version.php';
|
||||
}
|
||||
|
||||
self::$_assert_type_compatability = version_compare(PHPUnit_Runner_Version::id(), '3.5.0', '<=');
|
||||
}
|
||||
|
||||
$this->_helpers = new Kohana_Unittest_Helpers;
|
||||
$this->_helpers = new Unittest_Helpers;
|
||||
|
||||
$this->setEnvironment($this->environmentDefault);
|
||||
}
|
||||
@@ -70,7 +71,7 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public function cleanCacheDir()
|
||||
{
|
||||
return Kohana_Unittest_Helpers::clean_cache_dir();
|
||||
return Unittest_Helpers::clean_cache_dir();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +83,7 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public function dirSeparator($path)
|
||||
{
|
||||
return Kohana_Unittest_Helpers::dir_separator($path);
|
||||
return Unittest_Helpers::dir_separator($path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +109,7 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public function hasInternet()
|
||||
{
|
||||
return Kohana_Unittest_Helpers::has_internet();
|
||||
return Unittest_Helpers::has_internet();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,10 +122,8 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public static function assertInstanceOf($expected, $actual, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertType($expected, $actual, $message);
|
||||
}
|
||||
|
||||
return parent::assertInstanceOf($expected, $actual, $message);
|
||||
}
|
||||
@@ -140,10 +139,8 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public static function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertAttributeType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
|
||||
return parent::assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
@@ -158,10 +155,8 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public static function assertNotInstanceOf($expected, $actual, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertNotType($expected, $actual, $message);
|
||||
}
|
||||
|
||||
return self::assertNotInstanceOf($expected, $actual, $message);
|
||||
}
|
||||
@@ -177,10 +172,8 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public static function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertAttributeNotType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
|
||||
return self::assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
@@ -195,10 +188,8 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public static function assertInternalType($expected, $actual, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertType($expected, $actual, $message);
|
||||
}
|
||||
|
||||
return parent::assertInternalType($expected, $actual, $message);
|
||||
}
|
||||
@@ -214,10 +205,8 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public static function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertAttributeType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
|
||||
return self::assertAttributeInternalType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
@@ -232,10 +221,8 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public static function assertNotInternalType($expected, $actual, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertNotType($expected, $actual, $message);
|
||||
}
|
||||
|
||||
return self::assertNotInternalType($expected, $actual, $message);
|
||||
}
|
||||
@@ -251,10 +238,8 @@ abstract class Kohana_Unittest_TestCase extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public static function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '')
|
||||
{
|
||||
if(self::$_assert_type_compatability)
|
||||
{
|
||||
if (self::$_assert_type_compatability)
|
||||
return self::assertAttributeNotType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
|
||||
return self::assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message);
|
||||
}
|
||||
|
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* PHPUnit testsuite for kohana application
|
||||
*
|
||||
* @package Kohana/Unittest
|
||||
* @package Kohana/UnitTest
|
||||
* @author Kohana Team
|
||||
* @author BRMatt <matthew@sigswitch.com>
|
||||
* @author Paul Banks
|
||||
* @copyright (c) 2008-2009 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
*/
|
||||
class Kohana_Tests
|
||||
{
|
||||
class Kohana_Unittest_Tests {
|
||||
static protected $cache = array();
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,6 @@ class Kohana_Tests
|
||||
{
|
||||
include_once 'PHPUnit/Framework.php';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Allow PHPUnit to handle exceptions and errors
|
||||
@@ -66,13 +65,13 @@ class Kohana_Tests
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
spl_autoload_register(array('Kohana_Tests', 'autoload'));
|
||||
spl_autoload_register(array('Unittest_tests', 'autoload'));
|
||||
|
||||
Kohana_Tests::$cache = (($cache = Kohana::cache('unittest_whitelist_cache')) === NULL) ? array() : $cache;
|
||||
|
||||
// As of PHPUnit v3.5 there are slight differences in the way files are black|whitelisted
|
||||
self::$phpunit_v35 = function_exists('phpunit_autoload');
|
||||
|
||||
Unittest_tests::$cache = (($cache = Kohana::cache('unittest_whitelist_cache')) === NULL) ? array() : $cache;
|
||||
|
||||
$config = Kohana::config('unittest');
|
||||
|
||||
if ($do_whitelist AND $config->use_whitelist)
|
||||
@@ -82,7 +81,7 @@ class Kohana_Tests
|
||||
|
||||
if ($do_blacklist AND count($config['blacklist']))
|
||||
{
|
||||
Kohana_Tests::blacklist($config->blacklist);
|
||||
Unittest_tests::blacklist($config->blacklist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +131,9 @@ class Kohana_Tests
|
||||
* @param PHPUnit_Framework_TestSuite $suite The test suite to add to
|
||||
* @param array $files Array of files to test
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
static function addTests(PHPUnit_Framework_TestSuite $suite, array $files)
|
||||
// @codingStandardsIgnoreEnd
|
||||
{
|
||||
if (self::$phpunit_v35)
|
||||
{
|
||||
@@ -159,7 +160,7 @@ class Kohana_Tests
|
||||
{
|
||||
require_once($file);
|
||||
}
|
||||
|
||||
|
||||
if (isset($filter))
|
||||
{
|
||||
$filter->addFileToBlacklist($file);
|
||||
@@ -307,17 +308,17 @@ class Kohana_Tests
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! isset(Kohana_Tests::$cache[$file]))
|
||||
if ( ! isset(Unittest_tests::$cache[$file]))
|
||||
{
|
||||
$relative_path = substr($file, strrpos($file, 'classes'.DIRECTORY_SEPARATOR) + 8, -strlen(EXT));
|
||||
$cascading_file = Kohana::find_file('classes', $relative_path);
|
||||
|
||||
// The theory is that if this file is the highest one in the cascading filesystem
|
||||
// then it's safe to whitelist
|
||||
Kohana_Tests::$cache[$file] = ($cascading_file === $file);
|
||||
Unittest_tests::$cache[$file] = ($cascading_file === $file);
|
||||
}
|
||||
|
||||
if (Kohana_Tests::$cache[$file])
|
||||
if (Unittest_tests::$cache[$file])
|
||||
{
|
||||
if (isset($filter))
|
||||
{
|
@@ -0,0 +1,3 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Unittest_Helpers extends Kohana_Unittest_Helpers {}
|
@@ -0,0 +1,3 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Unittest_Runner extends Kohana_Unittest_Runner {}
|
@@ -0,0 +1,3 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Unittest_TestCase extends Kohana_Unittest_TestCase {}
|
@@ -0,0 +1,3 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Unittest_Tests extends Kohana_Unittest_Tests {}
|
Reference in New Issue
Block a user