Skip to content

Commit

Permalink
work around ConstraintValidatorTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Apr 6, 2024
1 parent 5fe612c commit cc4d043
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Model/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Route extends SymfonyRoute implements RouteObjectInterface
/**
* Unique id of this route.
*/
protected string|int|null $id;
protected string|int|null $id = null;

/**
* The referenced content object.
Expand Down
2 changes: 1 addition & 1 deletion src/Routing/RedirectableRequestMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Cmf\Bundle\RoutingBundle\Routing;

use Symfony\Cmf\Bundle\RoutingBundle\Controller\RedirectController;
use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\ExceptionInterface;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
use Symfony\Cmf\Bundle\RoutingBundle\Validator\Constraints\RouteDefaults;
use Symfony\Cmf\Bundle\RoutingBundle\Validator\Constraints\RouteDefaultsTwigValidator;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
use Symfony\Component\Validator\Test\ConstraintViolationAssertion;
use Twig\Loader\LoaderInterface;

class RouteDefaultsTwigValidatorTest extends ConstraintValidatorTestCase
Expand Down Expand Up @@ -66,7 +68,7 @@ public function testControllerPathViolation(): void

$this->validator->validate(['_controller' => 'NotExistingBundle:Foo:bar'], new RouteDefaults());

$this->buildViolation('Invalid controller')->assertRaised();
(new ConstraintViolationAssertion($this->context, 'Invalid controller', new NotNull()))->assertRaised();
}

public function testCorrectTemplate(): void
Expand Down Expand Up @@ -94,8 +96,9 @@ public function testTemplateViolation(): void
new RouteDefaults(['message' => 'my message'])
);

$this->buildViolation('my message')
(new ConstraintViolationAssertion($this->context, 'my message', new NotNull()))
->setParameter('%name%', 'NotExistingBundle:Foo:bar.html.twig')
->assertRaised();
->assertRaised()
;
}
}

0 comments on commit cc4d043

Please sign in to comment.