JsonValidationExceptionTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\Json;
  12. use Composer\Json\JsonValidationException;
  13. use Composer\Test\TestCase;
  14. class JsonValidationExceptionTest extends TestCase
  15. {
  16. /**
  17. * @dataProvider errorProvider
  18. */
  19. public function testGetErrors($message, $errors)
  20. {
  21. $object = new JsonValidationException($message, $errors);
  22. $this->assertEquals($message, $object->getMessage());
  23. $this->assertEquals($errors, $object->getErrors());
  24. }
  25. public function testGetErrorsWhenNoErrorsProvided()
  26. {
  27. $object = new JsonValidationException('test message');
  28. $this->assertEquals(array(), $object->getErrors());
  29. }
  30. public function errorProvider()
  31. {
  32. return array(
  33. array('test message', array()),
  34. array(null, null),
  35. );
  36. }
  37. }