-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility with FrameworkBundle Test Traits #39
Comments
Hm.. I added that method in the Symfony code base. What about removing it from |
I took a closer look and yes, this could be a good idea. I have already tested how it is usable: <?php
namespace SoureCode\Bundle\Token\Tests;
use DAMA\DoctrineTestBundle\DAMADoctrineTestBundle;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Nyholm\BundleTest\AppKernel;
use Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use MyCustomBundle;
abstract class MyAbstractBundleTestCase extends KernelTestCase
{
protected static function createKernel(array $options = [])
{
KernelTestCase::$class = AppKernel::class;
/**
* @var AppKernel $kernel
*/
$kernel = parent::createKernel($options);
$kernel->addBundle(DoctrineBundle::class);
$kernel->addBundle(DAMADoctrineTestBundle::class);
$kernel->addBundle(StofDoctrineExtensionsBundle::class);
$kernel->addBundle(MyCustomBundle::class);
$kernel->addConfigFile(__DIR__.'/config.yml');
return $kernel;
}
} To use it like this we need to take some changes in the
|
I just noticed that the
BaseBundleTestCase
class is not compatible with the FrameworkBundle AssertionTraits.In the trait
MailerAssertionsTrait
thegetContainer
function is statically called, cause it is expected that the trait will be used in theKernelTestCase
which have all the kernel and functions static.Unfortunately the
BaseBundleTestCase
uses non-static variables and functions and causes errors like these:I see three possible solutions:
$this
, but this also means more maintenance.// EDIT
Also noticed that the KernelTextCase returns the
test.service_container
to allow access to private services.The text was updated successfully, but these errors were encountered: