JsonValidationExceptionTest.php 1.0 KB

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