aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/HistoryTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/HistoryTest.php')
-rw-r--r--tests/HistoryTest.php17
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/HistoryTest.php b/tests/HistoryTest.php
index 7189c3a9..6dc0e5b7 100644
--- a/tests/HistoryTest.php
+++ b/tests/HistoryTest.php
@@ -3,10 +3,9 @@
3namespace Shaarli; 3namespace Shaarli;
4 4
5use DateTime; 5use DateTime;
6use Exception;
7use Shaarli\Bookmark\Bookmark; 6use Shaarli\Bookmark\Bookmark;
8 7
9class HistoryTest extends \PHPUnit\Framework\TestCase 8class HistoryTest extends \Shaarli\TestCase
10{ 9{
11 /** 10 /**
12 * @var string History file path 11 * @var string History file path
@@ -16,7 +15,7 @@ class HistoryTest extends \PHPUnit\Framework\TestCase
16 /** 15 /**
17 * Delete history file. 16 * Delete history file.
18 */ 17 */
19 public function setUp() 18 protected function setUp(): void
20 { 19 {
21 if (file_exists(self::$historyFilePath)) { 20 if (file_exists(self::$historyFilePath)) {
22 unlink(self::$historyFilePath); 21 unlink(self::$historyFilePath);
@@ -44,12 +43,12 @@ class HistoryTest extends \PHPUnit\Framework\TestCase
44 43
45 /** 44 /**
46 * Not writable history file: raise an exception. 45 * Not writable history file: raise an exception.
47 *
48 * @expectedException Exception
49 * @expectedExceptionMessage History file isn't readable or writable
50 */ 46 */
51 public function testConstructNotWritable() 47 public function testConstructNotWritable()
52 { 48 {
49 $this->expectException(\Exception::class);
50 $this->expectExceptionMessage('History file isn\'t readable or writable');
51
53 touch(self::$historyFilePath); 52 touch(self::$historyFilePath);
54 chmod(self::$historyFilePath, 0440); 53 chmod(self::$historyFilePath, 0440);
55 $history = new History(self::$historyFilePath); 54 $history = new History(self::$historyFilePath);
@@ -58,12 +57,12 @@ class HistoryTest extends \PHPUnit\Framework\TestCase
58 57
59 /** 58 /**
60 * Not parsable history file: raise an exception. 59 * Not parsable history file: raise an exception.
61 *
62 * @expectedException Exception
63 * @expectedExceptionMessageRegExp /Could not parse history file/
64 */ 60 */
65 public function testConstructNotParsable() 61 public function testConstructNotParsable()
66 { 62 {
63 $this->expectException(\Exception::class);
64 $this->expectExceptionMessageRegExp('/Could not parse history file/');
65
67 file_put_contents(self::$historyFilePath, 'not parsable'); 66 file_put_contents(self::$historyFilePath, 'not parsable');
68 $history = new History(self::$historyFilePath); 67 $history = new History(self::$historyFilePath);
69 // gzinflate generates a warning 68 // gzinflate generates a warning