Skip to content

Commit

Permalink
reset error_reporting value
Browse files Browse the repository at this point in the history
  • Loading branch information
saeideng committed Sep 24, 2017
1 parent 69f26e4 commit 41de250
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions tests/TestCase/Controller/ControllerTest.php
Expand Up @@ -236,6 +236,12 @@ class ControllerTest extends TestCase
'core.posts'
];

/**
* error level property
*
*/
private static $error_level;

/**
* reset environment.
*
Expand All @@ -258,6 +264,27 @@ public function tearDown()
{
parent::tearDown();
Plugin::unload();
error_reporting(self::$error_level);
}

/**
* setUpBeforeClass
*
* @return void
*/
public static function setUpBeforeClass()
{
self::$error_level = error_reporting();
}

/**
* tearDownAfterClass
*
* @return void
*/
public static function tearDownAfterClass()
{
error_reporting(self::$error_level);
}

/**
Expand Down Expand Up @@ -1098,12 +1125,10 @@ public function testBeforeRenderViewVariables()
public function testDeprecatedViewProperty($property, $getter, $setter, $value)
{
$controller = new AnotherTestController();
$error_level = error_reporting();
error_reporting(E_ALL ^ E_USER_DEPRECATED);
$controller->$property = $value;
$this->assertSame($value, $controller->$property);
$this->assertSame($value, $controller->viewBuilder()->{$getter}());
error_reporting($error_level);
}

/**
Expand All @@ -1120,11 +1145,9 @@ public function testDeprecatedViewProperty($property, $getter, $setter, $value)
*/
public function testDeprecatedViewPropertySetterMessage($property, $getter, $setter, $value)
{
$error_level = error_reporting();
error_reporting(E_ALL);
$controller = new AnotherTestController();
$controller->$property = $value;
error_reporting($error_level);
}

/**
Expand All @@ -1141,12 +1164,10 @@ public function testDeprecatedViewPropertySetterMessage($property, $getter, $set
*/
public function testDeprecatedViewPropertyGetterMessage($property, $getter, $setter, $value)
{
$error_level = error_reporting();
error_reporting(E_ALL);
$controller = new AnotherTestController();
$controller->viewBuilder()->{$setter}($value);
$result = $controller->$property;
error_reporting($error_level);
}

/**
Expand Down

0 comments on commit 41de250

Please sign in to comment.