History: lazy loading for the history file
Only read it when it's necessary
This commit is contained in:
parent
4306b184c4
commit
d16ca2e22f
2 changed files with 32 additions and 3 deletions
tests
|
@ -21,9 +21,19 @@ class HistoryTest extends PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* Test that the history file is created if it doesn't exist.
|
||||
*/
|
||||
public function testConstructFileCreated()
|
||||
public function testConstructLazyLoading()
|
||||
{
|
||||
new History(self::$historyFilePath);
|
||||
$this->assertFileNotExists(self::$historyFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the history file is created if it doesn't exist.
|
||||
*/
|
||||
public function testAddEventCreateFile()
|
||||
{
|
||||
$history = new History(self::$historyFilePath);
|
||||
$history->updateSettings();
|
||||
$this->assertFileExists(self::$historyFilePath);
|
||||
}
|
||||
|
||||
|
@ -37,7 +47,8 @@ class HistoryTest extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
touch(self::$historyFilePath);
|
||||
chmod(self::$historyFilePath, 0440);
|
||||
new History(self::$historyFilePath);
|
||||
$history = new History(self::$historyFilePath);
|
||||
$history->updateSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,8 +60,9 @@ class HistoryTest extends PHPUnit_Framework_TestCase
|
|||
public function testConstructNotParsable()
|
||||
{
|
||||
file_put_contents(self::$historyFilePath, 'not parsable');
|
||||
$history = new History(self::$historyFilePath);
|
||||
// gzinflate generates a warning
|
||||
@new History(self::$historyFilePath);
|
||||
@$history->updateSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue