|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony CMF package. |
| 5 | + * |
| 6 | + * (c) 2011-2017 Symfony CMF |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\Doctrine\Orm; |
| 13 | + |
| 14 | +use Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\BaseTestCase; |
| 15 | +use Symfony\Cmf\Component\Routing\RedirectRouteInterface; |
| 16 | +use Symfony\Cmf\Bundle\RoutingBundle\Model\RedirectRoute; |
| 17 | + |
| 18 | +class RedirectRouteTest extends OrmTestCase |
| 19 | +{ |
| 20 | + private $repository; |
| 21 | + |
| 22 | + public function setUp() |
| 23 | + { |
| 24 | + parent::setUp(); |
| 25 | + $this->clearDb(Route::class); |
| 26 | + |
| 27 | + $this->repository = $this->getContainer()->get('cmf_routing.route_provider'); |
| 28 | + } |
| 29 | + |
| 30 | + public function testRedirectDoctrine() |
| 31 | + { |
| 32 | + $route = $this->createRoute('route1', '/test'); |
| 33 | + |
| 34 | + $redirectRouteDoc = new RedirectRoute(); |
| 35 | + $redirectRouteDoc->setRouteName("redirect1"); |
| 36 | + $redirectRouteDoc->setRouteTarget($route); |
| 37 | + $redirectRouteDoc->setPermanent(true); |
| 38 | + |
| 39 | + $this->getDm()->flush(); |
| 40 | + |
| 41 | + $redirectRoute = new Route(); |
| 42 | + $redirectRoute->setName("redirect1"); |
| 43 | + $redirectRoute->setStaticPrefix('/redirect'); |
| 44 | + $redirectRoute->setContent($redirectRouteDoc); |
| 45 | + |
| 46 | + $this->getDm()->flush(); |
| 47 | + $this->getDm()->clear(); |
| 48 | + |
| 49 | + $route1 = $this->repository->getRouteByName('route1'); |
| 50 | + $redirect1 = $this->repository->getRouteByName('redirect1'); |
| 51 | + $this->assertInstanceOf(Route::class, $route1); |
| 52 | + $this->assertInstanceOf(RedirectRouteInterface::class, $redirect1); |
| 53 | + |
| 54 | + $this->assertSame($route1, $redirect1->getContent()->getRouteTarget()); |
| 55 | + } |
| 56 | + |
| 57 | +} |
0 commit comments