X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FHistoryTest.php;h=6dc0e5b7aa112e19f3dd7cbc6f820356885f3088;hb=a5a9cf23acd1248585173aa32757d9720b5f2d62;hp=7189c3a99fb171dd436834252b7243eaa59a3d23;hpb=e26e2060f5470ce8bf4c5973284bae07b8af170a;p=github%2Fshaarli%2FShaarli.git 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 @@ namespace Shaarli; use DateTime; -use Exception; use Shaarli\Bookmark\Bookmark; -class HistoryTest extends \PHPUnit\Framework\TestCase +class HistoryTest extends \Shaarli\TestCase { /** * @var string History file path @@ -16,7 +15,7 @@ class HistoryTest extends \PHPUnit\Framework\TestCase /** * Delete history file. */ - public function setUp() + protected function setUp(): void { if (file_exists(self::$historyFilePath)) { unlink(self::$historyFilePath); @@ -44,12 +43,12 @@ class HistoryTest extends \PHPUnit\Framework\TestCase /** * Not writable history file: raise an exception. - * - * @expectedException Exception - * @expectedExceptionMessage History file isn't readable or writable */ public function testConstructNotWritable() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('History file isn\'t readable or writable'); + touch(self::$historyFilePath); chmod(self::$historyFilePath, 0440); $history = new History(self::$historyFilePath); @@ -58,12 +57,12 @@ class HistoryTest extends \PHPUnit\Framework\TestCase /** * Not parsable history file: raise an exception. - * - * @expectedException Exception - * @expectedExceptionMessageRegExp /Could not parse history file/ */ public function testConstructNotParsable() { + $this->expectException(\Exception::class); + $this->expectExceptionMessageRegExp('/Could not parse history file/'); + file_put_contents(self::$historyFilePath, 'not parsable'); $history = new History(self::$historyFilePath); // gzinflate generates a warning