2017-02-10 04:05:13 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
2017-03-28 04:12:12 +00:00
|
|
|
namespace JKingWeb\Arsse;
|
2017-02-10 04:05:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestException extends \PHPUnit\Framework\TestCase {
|
2017-02-16 20:29:42 +00:00
|
|
|
use Test\Tools;
|
2017-02-10 04:05:13 +00:00
|
|
|
|
2017-03-28 22:50:00 +00:00
|
|
|
function setUp() {
|
|
|
|
$this->clearData(false);
|
|
|
|
$m = $this->getMockBuilder(Lang::class)->setMethods(['__invoke'])->getMock();
|
|
|
|
$m->expects($this->any())->method("__invoke")->with($this->anything(), $this->anything())->will($this->returnValue(""));
|
|
|
|
Data::$l = $m;
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
2017-02-10 04:05:13 +00:00
|
|
|
|
2017-03-28 22:50:00 +00:00
|
|
|
function tearDown() {
|
|
|
|
$this->clearData(true);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testBaseClass() {
|
|
|
|
$this->assertException("unknown");
|
|
|
|
throw new Exception("unknown");
|
|
|
|
}
|
2017-02-10 04:05:13 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
/**
|
2017-02-11 18:50:34 +00:00
|
|
|
* @depends testBaseClass
|
2017-02-10 04:05:13 +00:00
|
|
|
*/
|
2017-02-16 20:29:42 +00:00
|
|
|
function testBaseClassWithoutMessage() {
|
|
|
|
$this->assertException("unknown");
|
|
|
|
throw new Exception();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-02-11 18:50:34 +00:00
|
|
|
* @depends testBaseClass
|
2017-02-10 04:05:13 +00:00
|
|
|
*/
|
2017-02-16 20:29:42 +00:00
|
|
|
function testDerivedClass() {
|
|
|
|
$this->assertException("fileMissing", "Lang");
|
|
|
|
throw new Lang\Exception("fileMissing");
|
|
|
|
}
|
2017-02-10 04:05:13 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
/**
|
2017-02-11 18:50:34 +00:00
|
|
|
* @depends testDerivedClass
|
2017-02-10 04:05:13 +00:00
|
|
|
*/
|
2017-02-16 20:29:42 +00:00
|
|
|
function testDerivedClassWithMessageParameters() {
|
|
|
|
$this->assertException("fileMissing", "Lang");
|
|
|
|
throw new Lang\Exception("fileMissing", "en");
|
|
|
|
}
|
2017-02-11 18:50:34 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
/**
|
2017-02-11 18:50:34 +00:00
|
|
|
* @depends testBaseClass
|
|
|
|
*/
|
2017-02-16 20:29:42 +00:00
|
|
|
function testBaseClassWithUnknownCode() {
|
|
|
|
$this->assertException("uncoded");
|
|
|
|
throw new Exception("testThisExceptionMessageDoesNotExist");
|
|
|
|
}
|
2017-02-11 18:50:34 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
/**
|
2017-02-11 18:50:34 +00:00
|
|
|
* @depends testBaseClassWithUnknownCode
|
|
|
|
*/
|
2017-02-16 20:29:42 +00:00
|
|
|
function testDerivedClassWithMissingMessage() {
|
|
|
|
$this->assertException("uncoded");
|
|
|
|
throw new Lang\Exception("testThisExceptionMessageDoesNotExist");
|
|
|
|
}
|
2017-02-10 04:05:13 +00:00
|
|
|
}
|