2012-01-27 08:29:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of Composer.
|
|
|
|
*
|
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Composer\Test\Util;
|
|
|
|
|
|
|
|
use Composer\Util\ErrorHandler;
|
2018-11-12 14:23:32 +00:00
|
|
|
use Composer\Test\TestCase;
|
2012-01-27 08:29:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ErrorHandler test case
|
|
|
|
*/
|
|
|
|
class ErrorHandlerTest extends TestCase
|
|
|
|
{
|
2020-02-07 06:35:07 +00:00
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
ErrorHandler::register();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
restore_error_handler();
|
|
|
|
}
|
|
|
|
|
2012-01-27 08:29:07 +00:00
|
|
|
/**
|
|
|
|
* Test ErrorHandler handles notices
|
|
|
|
*/
|
|
|
|
public function testErrorHandlerCaptureNotice()
|
|
|
|
{
|
2012-03-18 20:16:36 +00:00
|
|
|
$this->setExpectedException('\ErrorException', 'Undefined index: baz');
|
2012-01-27 08:29:07 +00:00
|
|
|
|
|
|
|
$array = array('foo' => 'bar');
|
|
|
|
$array['baz'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test ErrorHandler handles warnings
|
|
|
|
*/
|
|
|
|
public function testErrorHandlerCaptureWarning()
|
|
|
|
{
|
2013-10-14 22:15:09 +00:00
|
|
|
$this->setExpectedException('\ErrorException', 'array_merge');
|
2012-01-27 08:29:07 +00:00
|
|
|
|
|
|
|
array_merge(array(), 'string');
|
|
|
|
}
|
2012-04-08 14:55:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test ErrorHandler handles warnings
|
2020-02-07 06:35:07 +00:00
|
|
|
* @doesNotPerformAssertions
|
2012-04-08 14:55:45 +00:00
|
|
|
*/
|
|
|
|
public function testErrorHandlerRespectsAtOperator()
|
|
|
|
{
|
|
|
|
@trigger_error('test', E_USER_NOTICE);
|
|
|
|
}
|
2012-01-27 08:29:07 +00:00
|
|
|
}
|