aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/HistoryTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-01-16 12:50:36 +0100
committerArthurHoaro <arthur@hoa.ro>2017-03-21 20:29:20 +0100
commitd16ca2e22f3d7325fc9593fccd8523eebe226567 (patch)
treea1e5fb646ec69240fd882269a2c85a452e081833 /tests/HistoryTest.php
parent4306b184c4471825f916d895b047ed03fdf58985 (diff)
downloadShaarli-d16ca2e22f3d7325fc9593fccd8523eebe226567.tar.gz
Shaarli-d16ca2e22f3d7325fc9593fccd8523eebe226567.tar.zst
Shaarli-d16ca2e22f3d7325fc9593fccd8523eebe226567.zip
History: lazy loading for the history file
Only read it when it's necessary
Diffstat (limited to 'tests/HistoryTest.php')
-rw-r--r--tests/HistoryTest.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/HistoryTest.php b/tests/HistoryTest.php
index 79322249..91525845 100644
--- a/tests/HistoryTest.php
+++ b/tests/HistoryTest.php
@@ -21,9 +21,19 @@ class HistoryTest extends PHPUnit_Framework_TestCase
21 /** 21 /**
22 * Test that the history file is created if it doesn't exist. 22 * Test that the history file is created if it doesn't exist.
23 */ 23 */
24 public function testConstructFileCreated() 24 public function testConstructLazyLoading()
25 { 25 {
26 new History(self::$historyFilePath); 26 new History(self::$historyFilePath);
27 $this->assertFileNotExists(self::$historyFilePath);
28 }
29
30 /**
31 * Test that the history file is created if it doesn't exist.
32 */
33 public function testAddEventCreateFile()
34 {
35 $history = new History(self::$historyFilePath);
36 $history->updateSettings();
27 $this->assertFileExists(self::$historyFilePath); 37 $this->assertFileExists(self::$historyFilePath);
28 } 38 }
29 39
@@ -37,7 +47,8 @@ class HistoryTest extends PHPUnit_Framework_TestCase
37 { 47 {
38 touch(self::$historyFilePath); 48 touch(self::$historyFilePath);
39 chmod(self::$historyFilePath, 0440); 49 chmod(self::$historyFilePath, 0440);
40 new History(self::$historyFilePath); 50 $history = new History(self::$historyFilePath);
51 $history->updateSettings();
41 } 52 }
42 53
43 /** 54 /**
@@ -49,8 +60,9 @@ class HistoryTest extends PHPUnit_Framework_TestCase
49 public function testConstructNotParsable() 60 public function testConstructNotParsable()
50 { 61 {
51 file_put_contents(self::$historyFilePath, 'not parsable'); 62 file_put_contents(self::$historyFilePath, 'not parsable');
63 $history = new History(self::$historyFilePath);
52 // gzinflate generates a warning 64 // gzinflate generates a warning
53 @new History(self::$historyFilePath); 65 @$history->updateSettings();
54 } 66 }
55 67
56 /** 68 /**