ErrorHandlerTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Test\Util;
  12. use Composer\Util\ErrorHandler;
  13. use Composer\Test\TestCase;
  14. /**
  15. * ErrorHandler test case
  16. *
  17. * @author Artem Lopata <biozshock@gmail.com>
  18. */
  19. class ErrorHandlerTest extends TestCase
  20. {
  21. /**
  22. * Test ErrorHandler handles notices
  23. */
  24. public function testErrorHandlerCaptureNotice()
  25. {
  26. $this->setExpectedException('\ErrorException', 'Undefined index: baz');
  27. ErrorHandler::register();
  28. $array = array('foo' => 'bar');
  29. $array['baz'];
  30. }
  31. /**
  32. * Test ErrorHandler handles warnings
  33. */
  34. public function testErrorHandlerCaptureWarning()
  35. {
  36. $this->setExpectedException('\ErrorException', 'array_merge(): Argument #2 is not an array');
  37. ErrorHandler::register();
  38. array_merge(array(), 'string');
  39. }
  40. /**
  41. * Test ErrorHandler handles warnings
  42. */
  43. public function testErrorHandlerRespectsAtOperator()
  44. {
  45. ErrorHandler::register();
  46. @trigger_error('test', E_USER_NOTICE);
  47. }
  48. }