-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* @author gaobinzhan <[email protected]> | ||
*/ | ||
|
||
|
||
namespace EasySwoole\EasySwoole\Test; | ||
|
||
|
||
use EasySwoole\Config\AbstractConfig; | ||
use EasySwoole\Config\TableConfig; | ||
use EasySwoole\EasySwoole\Config; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ConfigTest extends TestCase | ||
{ | ||
public function testStorageHandler() | ||
{ | ||
$config = new TableConfig(); | ||
$this->assertInstanceOf(AbstractConfig::class, Config::getInstance()->storageHandler($config)); | ||
} | ||
|
||
public function testGetConf() | ||
{ | ||
$conf = Config::getInstance()->getConf(); | ||
$this->assertEmpty($conf); | ||
} | ||
|
||
public function testSetConf() | ||
{ | ||
$bool = Config::getInstance()->setConf('test', 'easyswoole'); | ||
$this->assertTrue($bool); | ||
$this->assertEquals('easyswoole', Config::getInstance()->getConf('test')); | ||
} | ||
|
||
public function testLoad() | ||
{ | ||
$bool = Config::getInstance()->load(['test' => 'easyswoole']); | ||
$this->assertTrue($bool); | ||
|
||
$conf = Config::getInstance()->getConf(); | ||
$this->assertEquals(['test' => 'easyswoole'], $conf); | ||
} | ||
|
||
public function testMerge() | ||
{ | ||
$bool = Config::getInstance()->merge(['test' => 'easyswoole']); | ||
$this->assertTrue($bool); | ||
|
||
$conf = Config::getInstance()->getConf(); | ||
$this->assertEquals(['test' => 'easyswoole'], $conf); | ||
} | ||
|
||
public function testClear() | ||
{ | ||
$bool = Config::getInstance()->clear(); | ||
$this->assertTrue($bool); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* @author gaobinzhan <[email protected]> | ||
*/ | ||
|
||
|
||
namespace EasySwoole\EasySwoole\Test; | ||
|
||
|
||
use EasySwoole\Component\Di; | ||
use EasySwoole\Component\Event; | ||
use EasySwoole\EasySwoole\Logger; | ||
use EasySwoole\EasySwoole\SysConst; | ||
use EasySwoole\Log\LoggerInterface; | ||
use PHPUnit\Framework\TestCase; | ||
use PHPUnit\Framework\TestResult; | ||
|
||
class LoggerTest extends TestCase | ||
{ | ||
/** @var Logger */ | ||
private $logger; | ||
|
||
public function runTest() | ||
{ | ||
$logger = Di::getInstance()->get(SysConst::LOGGER_HANDLER); | ||
$this->logger = Logger::getInstance($logger); | ||
return parent::runTest(); // TODO: Change the autogenerated stub | ||
} | ||
|
||
public function testSetLogConsole() | ||
{ | ||
$this->assertInstanceOf(LoggerInterface::class, $this->logger->setLogConsole(true)); | ||
} | ||
|
||
public function testOnLog() | ||
{ | ||
$this->assertInstanceOf(Event::class, $this->logger->onLog()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* @author gaobinzhan <[email protected]> | ||
*/ | ||
|
||
|
||
namespace EasySwoole\EasySwoole\Test; | ||
|
||
|
||
use EasySwoole\Component\Di; | ||
use EasySwoole\Component\Event; | ||
use EasySwoole\EasySwoole\SysConst; | ||
use EasySwoole\EasySwoole\Trigger; | ||
use PHPUnit\Framework\TestCase; | ||
use PHPUnit\Framework\TestResult; | ||
|
||
class TriggerTest extends TestCase | ||
{ | ||
/** @var Trigger */ | ||
private $trigger; | ||
|
||
public function runTest() | ||
{ | ||
$trigger = Di::getInstance()->get(SysConst::TRIGGER_HANDLER); | ||
$this->trigger = Trigger::getInstance($trigger); | ||
return parent::runTest(); // TODO: Change the autogenerated stub | ||
} | ||
|
||
public function testOnError() | ||
{ | ||
$this->assertInstanceOf(Event::class, $this->trigger->onError()); | ||
} | ||
|
||
public function testOnException() | ||
{ | ||
$this->assertInstanceOf(Event::class, $this->trigger->onException()); | ||
} | ||
} |