Skip to content

Commit 229c796

Browse files
committed
throw exception instead of fatal error
1 parent 74676b6 commit 229c796

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

src/functions.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
*/
2222
function requireFile($file)
2323
{
24-
require_once $file;
24+
if (file_exists($file)) {
25+
require_once $file;
26+
} else {
27+
throw new \RuntimeException("File not found '$file'");
28+
}
2529
}
2630

2731
/**

tests/AutoloadTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class AutoloadTest extends \PHPUnit_Framework_TestCase
1515
{
1616
/**
1717
* @group psr4
18-
* @covers Fedora::Autoloader::Autoload::addPsr4
1918
**/
2019
public function testAddPsr4()
2120
{
@@ -26,7 +25,6 @@ public function testAddPsr4()
2625

2726
/**
2827
* @group psr4
29-
* @covers Fedora::Autoloader::Autoload::addPsr4
3028
**/
3129
public function testAddPsr4Order()
3230
{
@@ -40,7 +38,6 @@ public function testAddPsr4Order()
4038

4139
/**
4240
* @group classmap
43-
* @covers Fedora::Autoloader::Autoload::addClassMap
4441
**/
4542
public function testAddClassMap()
4643
{
@@ -56,7 +53,6 @@ public function testAddClassMap()
5653

5754
/**
5855
* @group classmap
59-
* @covers Fedora::Autoloader::Autoload::addClassMap
6056
**/
6157
public function testAddClassMapTemplate()
6258
{
@@ -67,7 +63,6 @@ public function testAddClassMapTemplate()
6763

6864
/**
6965
* @group classmap
70-
* @covers Fedora::Autoloader::Autoload::addClassMap
7166
**/
7267
public function testAddClassMapLowerCase()
7368
{
@@ -78,7 +73,6 @@ public function testAddClassMapLowerCase()
7873

7974
/**
8075
* @group classmap
81-
* @covers Fedora::Autoloader::Autoload::addClassMap
8276
**/
8377
public function testAddClassMapTemplateOrder()
8478
{
@@ -92,7 +86,6 @@ public function testAddClassMapTemplateOrder()
9286

9387
/**
9488
* @group classmap
95-
* @covers Fedora::Autoloader::Autoload::addClassMap
9689
**/
9790
public function testAddClassMapTemplateOrderBis()
9891
{
@@ -112,7 +105,6 @@ public function testAddClassMapTemplateOrderBis()
112105

113106
/**
114107
* @group psr0
115-
* @covers Fedora::Autoloader::Autoload::addIncludePath
116108
**/
117109
public function testAddIncludePath()
118110
{
@@ -138,7 +130,6 @@ public function testAddIncludePath()
138130

139131
/**
140132
* @group psr0
141-
* @covers Fedora::Autoloader::Autoload::addPsr0
142133
**/
143134
public function testAddPsr0Simple()
144135
{
@@ -157,7 +148,6 @@ public function testAddPsr0Simple()
157148

158149
/**
159150
* @group psr0
160-
* @covers Fedora::Autoloader::Autoload::addPsr0
161151
**/
162152
public function testAddPsr0ns1()
163153
{
@@ -170,7 +160,6 @@ public function testAddPsr0ns1()
170160

171161
/**
172162
* @group psr0
173-
* @covers Fedora::Autoloader::Autoload::addPsr0
174163
**/
175164
public function testAddPsr0ns2()
176165
{

tests/DependenciesTest.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,26 @@ public function testRequiredExists()
2727
$this->assertTrue(class_exists('Foo\\Bar\\Baz'));
2828
}
2929

30+
/**
31+
* @expectedException RuntimeException
32+
* @expectedExceptionMessageRegex /File Not Found.*AlsoNotExist/
33+
**/
34+
public function testRequiredNotExistsLast()
35+
{
36+
Dependencies::required(array(
37+
array(
38+
__DIR__.'/fixtures/DoesNotExist.php',
39+
__DIR__.'/fixtures/AlsoNotExist.php',
40+
), ));
41+
}
42+
43+
/**
44+
* @expectedException RuntimeException
45+
* @expectedExceptionMessageRegex /File Not Found.*DoesNotExist/
46+
**/
3047
public function testRequiredNotExists()
3148
{
32-
$this->markTestSkipped('Skipping until we can get this test to pass');
33-
//Dependencies::required(array(__DIR__.'/fixtures/DoesNotExist.php'));
49+
Dependencies::required(array(__DIR__.'/fixtures/DoesNotExist.php'));
3450
}
3551

3652
public function testRequiredFirstExists()

0 commit comments

Comments
 (0)