Permalink
Browse files

Simplified code, adjusted test

  • Loading branch information...
1 parent 2a03745 commit 97855b0bebe1cfdbc979c6445e1c62ec0edaca7f @samdark samdark committed Dec 15, 2016
Showing with 11 additions and 6 deletions.
  1. +1 −1 LogTarget.php
  2. +10 −5 tests/LogTargetTest.php
View
@@ -152,7 +152,7 @@ protected function collectSummary()
'ajax' => (int) $request->getIsAjax(),
'method' => $request->getMethod(),
'ip' => $request->getUserIP(),
- 'time' => $this->getRequestTime(),
+ 'time' => $_SERVER['REQUEST_TIME_FLOAT'],
'statusCode' => $response->statusCode,
'sqlCount' => $this->getSqlTotalCount(),
];
@@ -2,22 +2,27 @@
namespace yiiunit\extensions\debug;
+use Yii;
use yii\debug\LogTarget;
use yii\debug\Module;
class LogTargetTest extends TestCase
{
public function testGetRequestTime()
{
- $logTarget = new LogTarget(new Module('debug'));
- $actual = $this->invoke($logTarget, 'getRequestTime');
- $this->assertTrue(is_float($actual));
- $this->assertSame($_SERVER['REQUEST_TIME_FLOAT'],$actual);
+ Yii::$app->getRequest()->setUrl('dummy');
+
+ $module = new Module('debug');
+ $module->bootstrap(Yii::$app);
+
+ $logTarget = new LogTarget($module);
+ $data = $this->invoke($logTarget, 'collectSummary');
+ self::assertSame($_SERVER['REQUEST_TIME_FLOAT'], $data['time']);
}
protected function setUp()
{
parent::setUp();
$this->mockWebApplication();
}
-}
+}

0 comments on commit 97855b0

Please sign in to comment.