2017-02-10 04:05:13 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\NewsSync;
|
|
|
|
|
|
|
|
|
|
|
|
class TestException extends \PHPUnit\Framework\TestCase {
|
|
|
|
use TestingHelpers;
|
|
|
|
|
|
|
|
static function setUpBeforeClass() {
|
|
|
|
Lang::set("");
|
|
|
|
}
|
|
|
|
|
|
|
|
static function tearDownAfterClass() {
|
|
|
|
Lang::set(Lang::DEFAULT);
|
|
|
|
}
|
|
|
|
|
2017-02-11 18:50:34 +00:00
|
|
|
function testBaseClass() {
|
2017-02-10 04:05:13 +00:00
|
|
|
$this->assertException("unknown");
|
|
|
|
throw new Exception("unknown");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-02-11 18:50:34 +00:00
|
|
|
* @depends testBaseClass
|
2017-02-10 04:05:13 +00:00
|
|
|
*/
|
2017-02-11 18:50:34 +00:00
|
|
|
function testBaseClassWithoutMessage() {
|
2017-02-10 04:05:13 +00:00
|
|
|
$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-11 18:50:34 +00:00
|
|
|
function testDerivedClass() {
|
2017-02-10 04:05:13 +00:00
|
|
|
$this->assertException("fileMissing", "Lang");
|
|
|
|
throw new Lang\Exception("fileMissing");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-02-11 18:50:34 +00:00
|
|
|
* @depends testDerivedClass
|
2017-02-10 04:05:13 +00:00
|
|
|
*/
|
2017-02-11 18:50:34 +00:00
|
|
|
function testDerivedClassWithMessageParameters() {
|
2017-02-10 04:05:13 +00:00
|
|
|
$this->assertException("fileMissing", "Lang");
|
|
|
|
throw new Lang\Exception("fileMissing", "en");
|
|
|
|
}
|
2017-02-11 18:50:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testBaseClass
|
|
|
|
*/
|
|
|
|
function testBaseClassWithUnknownCode() {
|
|
|
|
$this->assertException("uncoded");
|
|
|
|
throw new Exception("testThisExceptionMessageDoesNotExist");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testBaseClass
|
|
|
|
*/
|
|
|
|
function testBaseClassWithMissingMessage() {
|
|
|
|
$this->assertException("stringMissing", "Lang");
|
|
|
|
throw new Exception("invalid");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testBaseClassWithUnknownCode
|
|
|
|
*/
|
|
|
|
function testDerivedClassWithMissingMessage() {
|
|
|
|
$this->assertException("uncoded");
|
|
|
|
throw new Lang\Exception("testThisExceptionMessageDoesNotExist");
|
|
|
|
}
|
|
|
|
|
2017-02-10 04:05:13 +00:00
|
|
|
}
|