ErrorHandlerTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 in ' . __FILE__);
  27. ErrorHandler::set();
  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 in ' . __FILE__);
  37. ErrorHandler::set();
  38. array_merge(array(), 'string');
  39. }
  40. }