This repository has been archived by the owner on Jul 28, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow "friendsofsymfony/rest-bundle:^3.0"
- Loading branch information
Showing
7 changed files
with
216 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<routes xmlns="http://friendsofsymfony.github.com/schema/rest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://friendsofsymfony.github.com/schema/rest https://raw.github.com/FriendsOfSymfony/FOSRestBundle/master/Resources/config/schema/routing/rest_routing-1.0.xsd"> | ||
<import type="rest" resource="Sonata\NotificationBundle\Controller\Api\MessageController" name-prefix="sonata_api_notification_message_"/> | ||
<routes xmlns="http://symfony.com/schema/routing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd"> | ||
<import type="annotation" resource="Sonata\NotificationBundle\Controller\Api\MessageController" name-prefix="sonata_api_notification_message_"/> | ||
</routes> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\NotificationBundle\Tests\App; | ||
|
||
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; | ||
use FOS\RestBundle\FOSRestBundle; | ||
use JMS\SerializerBundle\JMSSerializerBundle; | ||
use Nelmio\ApiDocBundle\NelmioApiDocBundle; | ||
use Sonata\NotificationBundle\SonataNotificationBundle; | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
use Symfony\Bundle\SecurityBundle\SecurityBundle; | ||
use Symfony\Bundle\TwigBundle\TwigBundle; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Kernel; | ||
use Symfony\Component\Routing\RouteCollectionBuilder; | ||
|
||
final class AppKernel extends Kernel | ||
{ | ||
use MicroKernelTrait; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct('test', false); | ||
} | ||
|
||
public function registerBundles() | ||
{ | ||
return [ | ||
new FrameworkBundle(), | ||
new SecurityBundle(), | ||
new TwigBundle(), | ||
new FOSRestBundle(), | ||
new SonataNotificationBundle(), | ||
new JMSSerializerBundle(), | ||
new DoctrineBundle(), | ||
new NelmioApiDocBundle(), | ||
]; | ||
} | ||
|
||
public function getCacheDir(): string | ||
{ | ||
return $this->getBaseDir().'cache'; | ||
} | ||
|
||
public function getLogDir(): string | ||
{ | ||
return $this->getBaseDir().'log'; | ||
} | ||
|
||
public function getProjectDir(): string | ||
{ | ||
return __DIR__; | ||
} | ||
|
||
protected function configureRoutes(RouteCollectionBuilder $routes) | ||
{ | ||
$routes->import($this->getProjectDir().'/config/routes.yaml'); | ||
} | ||
|
||
protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void | ||
{ | ||
$containerBuilder->register('templating')->setSynthetic(true); | ||
$containerBuilder->register('templating.locator')->setSynthetic(true); | ||
$containerBuilder->register('templating.name_parser')->setSynthetic(true); | ||
$containerBuilder->register('mailer')->setSynthetic(true); | ||
|
||
$containerBuilder->loadFromExtension('framework', [ | ||
'secret' => '50n474.U53r', | ||
'session' => [ | ||
'handler_id' => 'session.handler.native_file', | ||
'storage_id' => 'session.storage.mock_file', | ||
'name' => 'MOCKSESSID', | ||
], | ||
'translator' => null, | ||
'validation' => [ | ||
'enabled' => true, | ||
], | ||
'form' => [ | ||
'enabled' => true, | ||
], | ||
'assets' => null, | ||
'test' => true, | ||
'profiler' => [ | ||
'enabled' => true, | ||
'collect' => false, | ||
], | ||
]); | ||
|
||
$containerBuilder->loadFromExtension('security', [ | ||
'firewalls' => ['api' => ['anonymous' => true]], | ||
'providers' => ['in_memory' => ['memory' => null]], | ||
]); | ||
|
||
$containerBuilder->loadFromExtension('twig', [ | ||
'strict_variables' => '%kernel.debug%', | ||
'exception_controller' => null, | ||
]); | ||
|
||
$containerBuilder->loadFromExtension('doctrine', [ | ||
'dbal' => [ | ||
'connections' => [ | ||
'default' => [ | ||
'driver' => 'pdo_sqlite', | ||
], | ||
], | ||
], | ||
'orm' => [ | ||
'default_entity_manager' => 'default', | ||
], | ||
]); | ||
|
||
$containerBuilder->loadFromExtension('fos_rest', [ | ||
'param_fetcher_listener' => true, | ||
]); | ||
} | ||
|
||
private function getBaseDir(): string | ||
{ | ||
return sys_get_temp_dir().'/sonata-notification-bundle/var/'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#NelmioApiDocBundle: | ||
# prefix: /api/doc | ||
# resource: "@NelmioApiDocBundle/Resources/config/routing.yml" | ||
|
||
sonata_api_notification: | ||
prefix: /api/notification | ||
resource: "@SonataNotificationBundle/Resources/config/routing/api.xml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\NotificationBundle\Tests\Functional\Routing; | ||
|
||
use Sonata\NotificationBundle\Tests\App\AppKernel; | ||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
|
||
/** | ||
* @author Javier Spagnoletti <phansys@gmail.com> | ||
*/ | ||
final class RoutingTest extends WebTestCase | ||
{ | ||
/** | ||
* @group legacy | ||
* | ||
* @dataProvider getRoutes | ||
*/ | ||
public function testRoutes(string $name, string $path, array $methods): void | ||
{ | ||
$client = static::createClient(); | ||
$router = $client->getContainer()->get('router'); | ||
|
||
$route = $router->getRouteCollection()->get($name); | ||
|
||
$this->assertNotNull($route); | ||
$this->assertSame($path, $route->getPath()); | ||
$this->assertEmpty(array_diff($methods, $route->getMethods())); | ||
} | ||
|
||
public function getRoutes(): iterable | ||
{ | ||
//yield ['nelmio_api_doc_index', '/api/doc/{view}', ['GET']]; | ||
yield ['sonata_api_notification_message_get_messages', '/api/notification/messages', ['GET']]; | ||
yield ['sonata_api_notification_message_post_message', '/api/notification/messages', ['POST']]; | ||
} | ||
|
||
protected static function getKernelClass(): string | ||
{ | ||
return AppKernel::class; | ||
} | ||
} |