Giter VIP home page Giter VIP logo

symfony-bundle-test's People

Contributors

alexandre-t avatar baachi avatar bocharsky-bw avatar chapterjason avatar chris53897 avatar fbourigault avatar grahamcampbell avatar guillaumesmo avatar jderusse avatar jean85 avatar kbond avatar kocal avatar l-vo avatar loevgaard avatar mbabker avatar mwadon avatar nemo64 avatar nyholm avatar smoench avatar stloyd avatar umpirsky avatar vincentchalamon avatar xabbuh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symfony-bundle-test's Issues

Errors with missing kernel service and router

Hey,

I use the Mailer with TemplatedEmail and Twig and get the following error:

Twig\Error\RuntimeError : An exception has been thrown during the rendering of a template ("Invalid resource "kernel:loadRoutes" passed to the "service" route loader: use the format "object_id::method" or "object_id" if your object class has an "__invoke" method.").

After I patched my copy like this: (https://github.com/SymfonyTest/symfony-bundle-test/blob/master/src/AppKernel.php#L122-L127)

            $container->loadFromExtension('framework', [
                'router' => [
-                    'resource' => 'kernel:loadRoutes',
+                    'resource' => 'kernel::loadRoutes',
                    'type' => 'service',
                ],
            ]);

I get this error:

Twig\Error\RuntimeError : An exception has been thrown during the rendering of a template ("Service "kernel" not found: the container inside "Symfony\Component\DependencyInjection\Argument\ServiceLocator" is a smaller service locator that is empty...").

I already tried to define the kernel in the container directly with something like this:

$container->set('kernel', $kernel);

But unfortunately this doesn't work.

1.8.2 compatible with Symfony 6?

Looking at the release, it says it's compatible with Symfony 6. But with 1.8.2 installed I'm still getting:

Fatal error: Declaration of         
     Nyholm\BundleTest\AppKernel::getProjectDir() must be compatible with     
     Symfony\Component\HttpKernel\Kernel::getProjectDir(): string in          
     /project/vendor/nyholm/symfony-bundle-test/src/AppKernel.php on line 94

I can see the signatures were updated in master, but not in 1.x. Is 1.x meant to be compatible with Symfony 6?

Future Symfony Versions

As I was working on some tests and the changes in the 6.0 branch in Symfony was made to add return types, I got a lot of errors about some methods in the kernel.

PHP Fatal error: Declaration of Nyholm\BundleTest\AppKernel::buildContainer() must be compatible with Symfony\Component\HttpKernel\Kernel::buildContainer(): Symfony\Component\DependencyInjection\ContainerBuilder in /[...]/vendor/nyholm/symfony-bundle-test/src/AppKernel.php on line 185
PHP Fatal error: Declaration of Nyholm\BundleTest\AppKernel::getCacheDir() must be compatible with Symfony\Component\HttpKernel\Kernel::getCacheDir(): string in /[...]/vendor/nyholm/symfony-bundle-test/src/AppKernel.php on line 81
PHP Fatal error: Declaration of Nyholm\BundleTest\AppKernel::getLogDir() must be compatible with Symfony\Component\HttpKernel\Kernel::getLogDir(): string in /[...]/vendor/nyholm/symfony-bundle-test/src/AppKernel.php on line 86
PHP Fatal error: Declaration of Nyholm\BundleTest\AppKernel::getProjectDir() must be compatible with Symfony\Component\HttpKernel\Kernel::getProjectDir(): string in /[...]/vendor/nyholm/symfony-bundle-test/src/AppKernel.php on line 91
PHP Fatal error: Declaration of Nyholm\BundleTest\AppKernel::registerBundles() must be compatible with Symfony\Component\HttpKernel\KernelInterface::registerBundles(): iterable in /[...]/vendor/nyholm/symfony-bundle-test/src/AppKernel.php on line 116

To make it work I had to change the return types:

public function registerBundles(): iterable;
protected function buildContainer(): ContainerBuilder;
public function getCacheDir(): string;
public function getLogDir(): string;
public function getProjectDir(): string;

I just wanted to open the issue first to discuss a solution, I can create the pull request then.

My first thought was a second kernel with compatible return types, but I'm not sure how to create that without a lot of duplication.

1.9.0 release

Are we able to get a final 1.x release, 1.9.0, please?

Accessing private services

This means that in tests accessing private services will not be caught as an error? I find this dangerous.

Release 3.0.0

Here are some of my thoughts on the next releases which already brings the Symfony 7 and PHP 8.3 Support in 3.x and some preparation in the 2.x branch which is missing, I will fix that the next days as follows:

2.1.0 (2.x)

  • Create 2.x branch from 0a83997
  • Backport some CI changes from f8260c0 #87
  • Implement #77 with compatibility layer (compatibility layer was actually not required, we have our own method.) #88
  • Rebase and merge #82
  • Release 2.1.0

3.0.0 (master)

  • #89
  • Update README
  • Remove compatibility layer from #77 Not required anymore
  • Release 3.0.0

WDYT?

// cc: @Nyholm

Compatibility with FrameworkBundle Test Traits

I just noticed that the BaseBundleTestCase class is not compatible with the FrameworkBundle AssertionTraits.

In the trait MailerAssertionsTrait the getContainer function is statically called, cause it is expected that the trait will be used in the KernelTestCase which have all the kernel and functions static.

Unfortunately the BaseBundleTestCase uses non-static variables and functions and causes errors like these:

Error : Non-static method Nyholm\BundleTest\BaseBundleTestCase::getContainer() cannot be called statically
 /[...]/vendor/symfony/framework-bundle/Test/MailerAssertionsTrait.php:121
 /[...]/vendor/symfony/framework-bundle/Test/MailerAssertionsTrait.php:25
 /[...]/Tests/ExampleTest.php:159

I see three possible solutions:

  1. We change the functions and variables to static, which would be a breaking change.
  2. We serve custom traits with the same functionality which uses $this, but this also means more maintenance.
  3. Combination of 1 and 2. We first serve custom traits to avoid a breaking change and change to static in version 2.0.

// EDIT
Also noticed that the KernelTextCase returns the test.service_container to allow access to private services.

Add CompilerPass with priority to TestKernel

Currently, you cannot set the $priority argument of ContainerBuilder::addCompilerPass(); when adding a CompilerPass to the TestKernel. In a few cases, this is needed, e.g. to run after another CompilerPass which alters the container (in my case: I am developing a bundle providing a custom translator implementation, before we can alter the translator in the pass of the bundle, the CompilerPass of the FrameworkBundle, which configures the Translator, must have ran).

I see these possibilities here:

  • Add a new method with more arguments (no BC break, but probably bad wording)
  • Change existing method (BC break, but still clear wording)
  • Or something else...?

I am willing to work on this, but I am not sure, which way shall I choose.

BaseBundleTestCase removal was not documented

In 1ea1ed9 the BaseBundleTestCase was removed, but that was not documented on the CHANGELOG.

As it was part of /src before in 1.x, maybe the preferred approach on how to upgrade to 2.x can get documented as well?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.