ErrorHandlerTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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\TestCase;
  14. /**
  15. * ErrorHandler test case
  16. */
  17. class ErrorHandlerTest extends TestCase
  18. {
  19. /**
  20. * Test ErrorHandler handles notices
  21. */
  22. public function testErrorHandlerCaptureNotice()
  23. {
  24. $this->setExpectedException('\ErrorException', 'Undefined index: baz');
  25. ErrorHandler::register();
  26. $array = array('foo' => 'bar');
  27. $array['baz'];
  28. }
  29. /**
  30. * Test ErrorHandler handles warnings
  31. */
  32. public function testErrorHandlerCaptureWarning()
  33. {
  34. $this->setExpectedException('\ErrorException', 'array_merge');
  35. ErrorHandler::register();
  36. array_merge(array(), 'string');
  37. }
  38. /**
  39. * Test ErrorHandler handles warnings
  40. */
  41. public function testErrorHandlerRespectsAtOperator()
  42. {
  43. ErrorHandler::register();
  44. @trigger_error('test', E_USER_NOTICE);
  45. }
  46. }