This repository has been archived by the owner on Sep 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
609 additions
and
46 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
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
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
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,36 @@ | ||
<?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\Twig\Extension; | ||
|
||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFilter; | ||
|
||
/** | ||
* @author Hugo Briand <briand@ekino.com> | ||
* @author Titouan Galopin <galopintitouan@gmail.com> | ||
*/ | ||
class StatusExtension extends AbstractExtension | ||
{ | ||
public function getFilters() | ||
{ | ||
return [ | ||
new TwigFilter('sonata_status_class', [StatusRuntime::class, 'statusClass']), | ||
]; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return 'sonata_twig_status'; | ||
} | ||
} |
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,79 @@ | ||
<?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\CoreBundle\Tests\App; | ||
|
||
use Sonata\CoreBundle\SonataCoreBundle; | ||
use Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle; | ||
use Symfony\Bundle\FrameworkBundle\Controller\TemplateController; | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
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\Route; | ||
use Symfony\Component\Routing\RouteCollectionBuilder; | ||
|
||
final class AppKernel extends Kernel | ||
{ | ||
use MicroKernelTrait; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct('test', false); | ||
} | ||
|
||
public function registerBundles(): array | ||
{ | ||
return [ | ||
new FrameworkBundle(), | ||
new TwigBundle(), | ||
new SonataDoctrineBundle(), | ||
new SonataCoreBundle(), | ||
]; | ||
} | ||
|
||
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): void | ||
{ | ||
$route = new Route('/'); | ||
$route->setDefault('_controller', TemplateController::class.'::templateAction'); | ||
$routes->setDefault('template', 'index.html.twig'); | ||
$routes->addRoute($route); | ||
} | ||
|
||
protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void | ||
{ | ||
$loader->load(__DIR__.'/config.yml'); | ||
} | ||
|
||
private function getBaseDir(): string | ||
{ | ||
return sys_get_temp_dir().'/sonata-project/core-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,11 @@ | ||
framework: | ||
secret: secret | ||
test: true | ||
session: | ||
handler_id: ~ | ||
storage_id: session.storage.mock_file | ||
name: 'MOCKSESSID' | ||
|
||
twig: | ||
paths: | ||
- '%kernel.project_dir%/templates' |
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,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Welcome!</title> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
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,46 @@ | ||
<?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\CoreBundle\Tests\Functional; | ||
|
||
use Sonata\CoreBundle\Tests\App\AppKernel; | ||
use Symfony\Bundle\FrameworkBundle\KernelBrowser; | ||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
use Symfony\Component\HttpKernel\KernelInterface; | ||
|
||
final class FunctionalTest extends WebTestCase | ||
{ | ||
public function testRenderFlashes(): void | ||
{ | ||
$kernel = new AppKernel(); | ||
|
||
$client = $this->createClientBC($kernel); | ||
$client->request('GET', '/'); | ||
|
||
$this->assertSame(200, $client->getResponse()->getStatusCode()); | ||
} | ||
|
||
protected static function getKernelClass(): string | ||
{ | ||
return AppKernel::class; | ||
} | ||
|
||
private function createClientBC(KernelInterface $kernel) | ||
{ | ||
if (class_exists(KernelBrowser::class)) { | ||
return new KernelBrowser($kernel); | ||
} | ||
|
||
return static::createClient(); | ||
} | ||
} |
Oops, something went wrong.