appCommonContext = new \Base\Common\Context('phpunit', 888); } protected function tearDown() { // 输出本次单元测试所执行的SQL语句 // var_dump(\PhalApi\DI()->tracer->getSqls()); // 输出本次单元测试所涉及的追踪埋点 // var_dump(\PhalApi\DI()->tracer->getStack()); } /** * @group testSetAppKey */ public function testSetAppKey() { $this->assertEquals('phpunit', $this->appCommonContext->getAppKey()); $appKey = 'phpunit2'; $rs = $this->appCommonContext->setAppKey($appKey); $this->assertEquals($appKey, $this->appCommonContext->getAppKey()); } /** * @group testGetAppKey */ public function testGetAppKey() { $rs = $this->appCommonContext->getAppKey(); $this->assertEquals('phpunit', $rs); } /** * @group testSetUid */ public function testSetUid() { $this->assertEquals(888, $this->appCommonContext->getUid()); $uid = '999'; $rs = $this->appCommonContext->setUid($uid); $this->assertSame(999, $rs->getUid()); } /** * @group testGetUid */ public function testGetUid() { $rs = $this->appCommonContext->getUid(); $this->assertEquals(888, $rs); } }