Skip to content

Commit

Permalink
[UiTranslations] Add test application
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Sep 20, 2024
1 parent a2bb6b4 commit 39da94e
Show file tree
Hide file tree
Showing 21 changed files with 316 additions and 19 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"TestApplication\\Sylius\\BootstrapAdminUi\\": "src/BootstrapAdminUi/tests/Functional/.application/src/",
"TestApplication\\Sylius\\TwigExtra\\": "src/TwigExtra/tests/Functional/.application/src/",
"TestApplication\\Sylius\\TwigHooks\\": "src/TwigHooks/tests/Functional/.application/src/",
"TestApplication\\Sylius\\UiTranslations\\": "src/UiTranslations/tests/Functional/.application/src/",
"Tests\\Sylius\\AdminUi\\": "src/AdminUi/tests/",
"Tests\\Sylius\\TwigExtra\\": "src/TwigExtra/tests/",
"Tests\\Sylius\\TwigHooks\\": "src/TwigHooks/tests/"
Expand Down
2 changes: 1 addition & 1 deletion config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Sylius\TwigHooks\TwigHooksBundle::class => ['all' => true],
Sylius\TwigExtra\Symfony\SyliusTwigExtraBundle::class => ['all' => true],
Sylius\AdminUi\Symfony\SyliusAdminUiBundle::class => ['all' => true],
Sylius\UiTranslations\Symfony\UiTranslationsBundle::class => ['all' => true],
Sylius\UiTranslations\Symfony\SyliusUiTranslationsBundle::class => ['all' => true],
Sylius\BootstrapAdminUi\Symfony\SyliusBootstrapAdminUiBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Expand Down
46 changes: 30 additions & 16 deletions src/UiTranslations/composer.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
{
"name": "sylius/ui-translations",
"description": "Basic UI translations",
"type": "library",
"require": {
"php": "^8.1",
"symfony/http-kernel": "^6.4 || ^7.0"
},
"autoload": {
"psr-4": {
"Sylius\\UiTranslations\\": "src/"
"name": "sylius/ui-translations",
"description": "Basic UI translations",
"type": "library",
"require": {
"php": "^8.1",
"symfony/translation": "^6.4 || ^7.0",
"symfony/yaml": "^6.4 || ^7.0"
},
"require-dev": {
"symfony/console": "^6.4 || ^7.0",
"symfony/dotenv": "^6.4 || ^7.0",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0"
},
"autoload": {
"psr-4": {
"Sylius\\UiTranslations\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"TestApplication\\Sylius\\UiTranslations\\": "tests/Functional/.application/src/",
"Tests\\Sylius\\UiTranslations\\": "tests/"
}
},
"config": {
"allow-plugins": {
"symfony/runtime": true
},
"sort-packages": true
}
},
"autoload-dev": {
"psr-4": {
"Tests\\Sylius\\UiTranslations\\": "tests/"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Symfony\Component\HttpKernel\Bundle\AbstractBundle;

final class UiTranslationsBundle extends AbstractBundle
final class SyliusUiTranslationsBundle extends AbstractBundle
{
public function getPath(): string
{
Expand Down
20 changes: 20 additions & 0 deletions src/UiTranslations/tests/Functional/.application/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
# https://symfony.com/doc/current/configuration/secrets.html
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=c9570eaa5cbfadf33ad1a93f95c2e42a
###< symfony/framework-bundle ###
12 changes: 12 additions & 0 deletions src/UiTranslations/tests/Functional/.application/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

composer.lock
21 changes: 21 additions & 0 deletions src/UiTranslations/tests/Functional/.application/bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env php
<?php

use Symfony\Bundle\FrameworkBundle\Console\Application;
use TestApplication\Sylius\UiTranslations\Kernel;

$_SERVER['APP_RUNTIME_OPTIONS'] = [
'project_dir' => dirname(__DIR__),
];

if (file_exists(dirname(__DIR__, 4).'/vendor/autoload_runtime.php')) {
require_once dirname(__DIR__, 4).'/vendor/autoload_runtime.php';
} else {
require_once dirname(__DIR__, 6).'/vendor/autoload_runtime.php';
}

return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);

return new Application($kernel);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

use Symfony\Component\Dotenv\Dotenv;

if (file_exists(dirname(__DIR__, 4) . '/vendor/autoload.php')) {
require_once dirname(__DIR__, 4) . '/vendor/autoload.php';
} else {
require_once dirname(__DIR__, 6) . '/vendor/autoload.php';
}

// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
if (is_array($env = @include dirname(__DIR__) . '/.env.local.php')) {
$_SERVER += $env;
$_ENV += $env;
} elseif (!class_exists(Dotenv::class)) {
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
} else {
// load all the .env files
(new Dotenv())->loadEnv(dirname(__DIR__) . '/.env');
}

$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Sylius\UiTranslations\Symfony\SyliusUiTranslationsBundle::class => ['all' => true],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
framework:
cache:
# Unique name of your app: used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name

# The "app" cache stores to the filesystem by default.
# The data in this cache should persist between deploys.
# Other options include:

# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost

# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu

# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: null
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Symfony\Component\HttpKernel\Kernel;

return static function (ContainerConfigurator $container): void {
if (Kernel::MAJOR_VERSION >= 6) {
$container->extension('framework', [
'handle_all_throwables' => true,
]);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
secret: '%env(APP_SECRET)%'
#csrf_protection: true
http_method_override: false

# Enables session support. Note that the session will ONLY be started if you read or write from it.
# Remove or comment this section to explicitly disable session support.
session:
handler_id: null
cookie_secure: auto
cookie_samesite: lax
storage_factory_id: session.storage.factory.native

#esi: true
#fragments: true

when@test:
framework:
test: true
session:
storage_factory_id: session.storage.factory.mock_file
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
framework:
router:
utf8: true

# Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
#default_uri: http://localhost

when@prod:
framework:
router:
strict_requirements: null
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

if (file_exists(dirname(__DIR__) . '/var/cache/prod/App_KernelProdContainer.preload.php')) {
require dirname(__DIR__) . '/var/cache/prod/App_KernelProdContainer.preload.php';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#index:
# path: /
# controller: App\Controller\DefaultController::index
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
when@dev:
_errors:
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
prefix: /_error
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:

services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
TestApplication\Sylius\UiTranslations\:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'

# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
24 changes: 24 additions & 0 deletions src/UiTranslations/tests/Functional/.application/public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

use TestApplication\Sylius\UiTranslations\Kernel;

if (file_exists(dirname(__DIR__, 4) . '/vendor/autoload_runtime.php')) {
require_once dirname(__DIR__, 4) . '/vendor/autoload_runtime.php';
} else {
require_once dirname(__DIR__, 6) . '/vendor/autoload_runtime.php';
}

return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
Empty file.
27 changes: 27 additions & 0 deletions src/UiTranslations/tests/Functional/.application/src/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace TestApplication\Sylius\UiTranslations;

use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;

class Kernel extends BaseKernel
{
use MicroKernelTrait;

public function getProjectDir(): string
{
return dirname(__DIR__);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Contracts\Translation\TranslatorInterface;

final class UiTranslationsBundleTest extends KernelTestCase
final class SyliusUiTranslationsBundleTest extends KernelTestCase
{
public function testItRegistersUiTranslations(): void
{
Expand Down

0 comments on commit 39da94e

Please sign in to comment.