mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Merge pull request #1174 from psparrow/master
Fixed issue with including including PHPUnit's Autoload script.
This commit is contained in:
commit
76ea0803d5
2 changed files with 41 additions and 2 deletions
38
lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php
Normal file
38
lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
class CakeTestSuiteDispatcherTest extends CakeTestCase {
|
||||
|
||||
public function setUp() {
|
||||
$this->vendors = App::path('vendors');
|
||||
$this->includePath = ini_get('include_path');
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
App::build(array('Vendor' => $this->vendors), App::RESET);
|
||||
ini_set('include_path', $this->includePath);
|
||||
}
|
||||
|
||||
protected function clearPaths() {
|
||||
App::build(array('Vendor' => array('junk')), App::RESET);
|
||||
ini_set('include_path', 'junk');
|
||||
}
|
||||
|
||||
public function testLoadTestFramework() {
|
||||
$dispatcher = new CakeTestSuiteDispatcher();
|
||||
|
||||
$this->assertTrue($dispatcher->loadTestFramework());
|
||||
|
||||
$this->clearPaths();
|
||||
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$dispatcher->loadTestFramework();
|
||||
} catch (Exception $ex) {
|
||||
$exception = $ex;
|
||||
}
|
||||
|
||||
$this->assertEquals(get_class($exception), "PHPUnit_Framework_Error_Warning");
|
||||
}
|
||||
|
||||
}
|
|
@ -138,13 +138,14 @@ class CakeTestSuiteDispatcher {
|
|||
*/
|
||||
public function loadTestFramework() {
|
||||
foreach (App::path('vendors') as $vendor) {
|
||||
if (is_dir($vendor . 'PHPUnit')) {
|
||||
$vendor = rtrim($vendor, DS);
|
||||
if (is_dir($vendor . DS . 'PHPUnit')) {
|
||||
ini_set('include_path', $vendor . PATH_SEPARATOR . ini_get('include_path'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return include 'PHPUnit' . DS . 'Autoload.php';
|
||||
return (include('PHPUnit' . DS . 'Autoload.php')) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue