Commit 1dad82a0 by Carsten Brandt

avoid random test break

parent 7af92173
<?php <?php
namespace yii\rbac;
/**
* Mock for the filemtime() function for rbac classes. Avoid random test fails.
* @return int
*/
function filemtime($file)
{
return \yiiunit\framework\rbac\PhpManagerTest::$filemtime ?: \filemtime($file);
}
namespace yiiunit\framework\rbac; namespace yiiunit\framework\rbac;
use Yii; use Yii;
...@@ -10,6 +21,8 @@ use Yii; ...@@ -10,6 +21,8 @@ use Yii;
*/ */
class PhpManagerTest extends ManagerTestCase class PhpManagerTest extends ManagerTestCase
{ {
public static $filemtime;
protected function getItemFile() protected function getItemFile()
{ {
return Yii::$app->getRuntimePath() . '/rbac-items.php'; return Yii::$app->getRuntimePath() . '/rbac-items.php';
...@@ -46,6 +59,7 @@ class PhpManagerTest extends ManagerTestCase ...@@ -46,6 +59,7 @@ class PhpManagerTest extends ManagerTestCase
protected function setUp() protected function setUp()
{ {
static::$filemtime = null;
parent::setUp(); parent::setUp();
$this->mockApplication(); $this->mockApplication();
$this->removeDataFiles(); $this->removeDataFiles();
...@@ -55,11 +69,13 @@ class PhpManagerTest extends ManagerTestCase ...@@ -55,11 +69,13 @@ class PhpManagerTest extends ManagerTestCase
protected function tearDown() protected function tearDown()
{ {
$this->removeDataFiles(); $this->removeDataFiles();
static::$filemtime = null;
parent::tearDown(); parent::tearDown();
} }
public function testSaveLoad() public function testSaveLoad()
{ {
static::$filemtime = time();
$this->prepareData(); $this->prepareData();
$items = $this->auth->items; $items = $this->auth->items;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment