Skip to content

Commit f3b7754

Browse files
committed
Add test for config with bad format
1 parent 4625649 commit f3b7754

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/Config.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public function load($filename)
3535
throw new ProfilerException("File does not exist: $filename");
3636
}
3737
$config = require $filename;
38+
if ($config === 1) {
39+
throw new ProfilerException("Config did not return an array: $filename");
40+
}
3841
$this->merge($config);
3942
}
4043

tests/ConfigTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,14 @@ public function testLoadConfig()
1919
$config->load(__DIR__ . '/Resources/config_saver.php');
2020
$this->assertEquals(Profiler::SAVER_UPLOAD, $config['save.handler']);
2121
}
22+
23+
/**
24+
* @expectedException \Xhgui\Profiler\Exception\ProfilerException
25+
* @expectedExceptionMessage Config did not return an array
26+
*/
27+
public function testBadConfig()
28+
{
29+
$config = new Config();
30+
$config->load(__DIR__ . '/Resources/config_bad_return.php');
31+
}
2232
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
use Xhgui\Profiler\Profiler;
4+
5+
$config = array(
6+
'save.handler' => Profiler::SAVER_UPLOAD,
7+
);

0 commit comments

Comments
 (0)