123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace Composer\Test\Util;
- use Composer\Util\Silencer;
- use Composer\Test\TestCase;
- class SilencerTest extends TestCase
- {
-
- public function testSilencer()
- {
- $before = error_reporting();
-
- Silencer::suppress();
- @trigger_error('Test', E_USER_WARNING);
- Silencer::restore();
-
- $result = Silencer::call(function ($a, $b, $c) {
- @trigger_error('Test', E_USER_WARNING);
- return $a * $b * $c;
- }, 2, 3, 4);
- $this->assertEquals(24, $result);
-
- $this->assertEquals($before, error_reporting());
- }
-
- public function testSilencedException()
- {
- $verification = microtime();
- $this->setExpectedException('\RuntimeException', $verification);
- Silencer::call(function () use ($verification) {
- throw new \RuntimeException($verification);
- });
- }
- }
|