for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Tests\Unit\Model;
use Happyr\JsonApiResponseFactory\Model\ErrorWithViolation;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\ConstraintViolationInterface;
/**
* @author Radoje Albijanic <[email protected]>
*/
class ErrorWithViolationTest extends TestCase
{
public function testCreate(): void
$violation = $this->getMockBuilder(ConstraintViolationInterface::class)
->getMock();
$violation->method('getPropertyPath')
->willReturn('someProperty');
$violation->method('getMessage')
->willReturn('someMessage');
$error = ErrorWithViolation::create($violation, 'someTitle');
self::assertEquals(
[
'status' => 400,
'title' => 'someTitle',
'source' => [
'parameter' => 'someProperty',
'message' => 'someMessage',
],
$error->getErrorData()
);
}