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
120 changed files
with
8,216 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -36,4 +36,3 @@ composer.lock | |
/vendor | ||
*.iml | ||
!test/bootstrap.php | ||
test |
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,52 @@ | ||
<?php | ||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: winglechen | ||
* Date: 16/5/7 | ||
* Time: 00:23 | ||
*/ | ||
|
||
namespace Zan\Framework\Test\Foundation\Container; | ||
|
||
use Zan\Framework\Foundation\Container\Container; | ||
use Zan\Framework\Test\Foundation\Container\Stub\Demo; | ||
use Zan\Framework\Test\Foundation\Container\Stub\Singleton; | ||
|
||
class ContainerTest extends \TestCase | ||
{ | ||
public function testMakeWork() | ||
{ | ||
$container = new Container(); | ||
|
||
$demoInstance = $container->make(Demo::class,[0,1]); | ||
$this->assertInstanceOf(Demo::class, $demoInstance, 'Container make instance failed'); | ||
$this->assertEquals(0, $demoInstance->getArg0(), 'demoInstance made by container getArg0 failed'); | ||
$this->assertEquals(1, $demoInstance->getArg1(), 'demoInstance made by container getArg1 failed'); | ||
} | ||
|
||
public function testMakeSharedInstanceWork() | ||
{ | ||
$container = new Container(); | ||
|
||
$singleton = $container->make(Singleton::class,['zan'],true); | ||
$this->assertInstanceOf(Singleton::class,$singleton,'container make Singleton fail'); | ||
$this->assertEquals('zan', $singleton->getUid(), 'singleton made by container getUid fail'); | ||
|
||
$singleton = $container->make(Singleton::class,['zanxxxx'],true); | ||
$this->assertInstanceOf(Singleton::class,$singleton,'container share Singleton fail'); | ||
$this->assertEquals('zan', $singleton->getUid(), 'container share singleton fail'); | ||
} | ||
|
||
public function testSingletonWork() | ||
{ | ||
$container = new Container(); | ||
|
||
$singleton = $container->make(Singleton::class,['zan']); | ||
$this->assertInstanceOf(Singleton::class,$singleton,'container make Singleton fail'); | ||
$this->assertEquals('zan', $singleton->getUid(), 'singleton made by container getUid fail'); | ||
|
||
$singleton = $container->make(Singleton::class,['zanxxxx']); | ||
$this->assertInstanceOf(Singleton::class,$singleton,'container share Singleton fail'); | ||
$this->assertEquals('zanxxxx', $singleton->getUid(), 'container share singleton fail'); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: winglechen | ||
* Date: 16/5/7 | ||
* Time: 00:26 | ||
*/ | ||
|
||
namespace Zan\Framework\Test\Foundation\Container\Stub; | ||
|
||
|
||
class Demo | ||
{ | ||
private $arg0; | ||
private $arg1; | ||
|
||
public function __construct($arg0, $arg1) | ||
{ | ||
|
||
$this->arg0 = $arg0; | ||
$this->arg1 = $arg1; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getArg0() | ||
{ | ||
return $this->arg0; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getArg1() | ||
{ | ||
return $this->arg1; | ||
} | ||
|
||
} |
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,28 @@ | ||
<?php | ||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: winglechen | ||
* Date: 16/5/7 | ||
* Time: 00:43 | ||
*/ | ||
|
||
namespace Zan\Framework\Test\Foundation\Container\Stub; | ||
|
||
|
||
class Singleton | ||
{ | ||
private $uid; | ||
|
||
public function __construct($uid) | ||
{ | ||
$this->uid = $uid; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getUid() | ||
{ | ||
return $this->uid; | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: heize | ||
* Date: 16/3/3 | ||
* Time: 上午10:53 | ||
*/ | ||
namespace Zan\Framework\Test\Foundation\Core; | ||
|
||
use Zan\Framework\Foundation\Core\ConfigLoader; | ||
|
||
class ConfigLoaderTest extends \TestCase { | ||
|
||
private $path; | ||
|
||
public function setUp() | ||
{ | ||
$this->path = __DIR__ . '/config/test'; | ||
} | ||
|
||
public function test(){ | ||
$config = new ConfigLoader(); | ||
$result = $config->load($this->path); | ||
$this->assertEquals('test', $result['a']['config'], 'ConfigLoader::load fail'); | ||
$this->assertEquals('pf', $result['pf']['b']['db'], 'ConfigLoader::load fail'); | ||
$this->assertEquals('pf', $result['pf']['a']['a'], 'ConfigLoader::load fail'); | ||
$this->assertEquals('test', $result['pf']['b']['test'], 'ConfigLoader::load fail'); | ||
} | ||
} |
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 | ||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: winglechen | ||
* Date: 15/12/18 | ||
* Time: 17:54 | ||
*/ | ||
|
||
namespace Zan\Framework\Test\Foundation\Core; | ||
|
||
use Zan\Framework\Foundation\Core\Config; | ||
use Zan\Framework\Foundation\Core\RunMode; | ||
use Zan\Framework\Foundation\Core\Path; | ||
|
||
class ConfigTest extends \TestCase | ||
{ | ||
private $configPath; | ||
private $config; | ||
private $runMode; | ||
|
||
public function setUp() | ||
{ | ||
$path = __DIR__ . '/config/'; | ||
$this->configPath = Path::getConfigPath(); | ||
Path::setConfigPath($path); | ||
$this->runMode = RunMode::get(); | ||
RunMode::set('test'); | ||
$config = new Config(); | ||
$this->config = $this->getProperty($config, "configMap"); | ||
Config::init(); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
$config = new Config(); | ||
$this->setPropertyValue($config, "configMap", $this->config); | ||
RunMode::set($this->runMode); | ||
Path::setConfigPath($this->configPath); | ||
} | ||
|
||
public function testGetConfigWork() | ||
{ | ||
$data = Config::get('a.share'); | ||
$this->assertEquals('share', $data, 'Config::get share get failed'); | ||
$data = Config::get('a.config'); | ||
$this->assertEquals('test', $data, 'Config::get share get failed'); | ||
$data = Config::get('pf.b.test'); | ||
$this->assertEquals('test', $data, 'Config::get share get failed'); | ||
$data = Config::get('pf.b.db'); | ||
$this->assertEquals('pf', $data, 'Config::get share get failed'); | ||
Config::set('pf.b.new','new'); | ||
$data = Config::get('pf.b.new'); | ||
$this->assertEquals('new', $data, 'Config::set failed'); | ||
Config::set('pf','delete'); | ||
$data = Config::get('pf'); | ||
$this->assertEquals('delete', $data, 'Config::set failed'); | ||
} | ||
|
||
} |
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,10 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: heize | ||
* Date: 16/3/3 | ||
* Time: 下午4:59 | ||
*/ | ||
return [ | ||
'config' => 'online', | ||
]; |
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,16 @@ | ||
<?php | ||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: winglechen | ||
* Date: 15/12/18 | ||
* Time: 18:00 | ||
*/ | ||
|
||
return [ | ||
'b' => [ | ||
'test' => 'online', | ||
'db' => 'online' | ||
], | ||
'evn' => 'online', | ||
'a' => 'online', | ||
]; |
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,12 @@ | ||
<?php | ||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: winglechen | ||
* Date: 15/12/18 | ||
* Time: 18:00 | ||
*/ | ||
|
||
return [ | ||
'test' => 'pf', | ||
'a' => 'pf', | ||
]; |
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,10 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: heize | ||
* Date: 16/3/4 | ||
* Time: 下午2:24 | ||
*/ | ||
return [ | ||
'db' => 'pf' | ||
]; |
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,12 @@ | ||
<?php | ||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: winglechen | ||
* Date: 15/12/18 | ||
* Time: 18:00 | ||
*/ | ||
|
||
return [ | ||
'config' => 'share', | ||
'share' => 'share' | ||
]; |
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,10 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: heize | ||
* Date: 16/3/3 | ||
* Time: 下午4:59 | ||
*/ | ||
return [ | ||
'config' => 'test', | ||
]; |
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,16 @@ | ||
<?php | ||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: winglechen | ||
* Date: 15/12/18 | ||
* Time: 18:00 | ||
*/ | ||
|
||
return [ | ||
'b' => [ | ||
'test' => 'test', | ||
'db' => 'test' | ||
], | ||
'evn' => 'test', | ||
'a' => 'test', | ||
]; |
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,12 @@ | ||
<?php | ||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: winglechen | ||
* Date: 15/12/18 | ||
* Time: 18:00 | ||
*/ | ||
|
||
return [ | ||
'test' => 'pf', | ||
'a' => 'pf', | ||
]; |
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,10 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: heize | ||
* Date: 16/3/4 | ||
* Time: 下午2:24 | ||
*/ | ||
return [ | ||
'db' => 'pf' | ||
]; |
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,21 @@ | ||
<?php | ||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: winglechen | ||
* Date: 16/3/17 | ||
* Time: 14:44 | ||
*/ | ||
|
||
namespace Zan\Framework\Test\Foundation\Coroutine; | ||
|
||
|
||
use Zan\Framework\Foundation\Coroutine\Task; | ||
|
||
class Base extends \TestCase{ | ||
public function testTaskWork() | ||
{ | ||
$coroutine = $this->step(); | ||
|
||
Task::execute($coroutine); | ||
} | ||
} |
Oops, something went wrong.