Symfony 4 – PHPUnit – Difficults with the setUp() method

I’m following the Symfony Cast Stripe formation. They use Symfony 3 and I use Symfony 4.

I try to make some test like in the formation : https://symfonycasts.com/screencast/stripe-level2/testing-webhooks#play

But when I run the test, I’ve this error :

Fatal error: Cannot redeclare static
SymfonyBundleFrameworkBundleTestWebTestCase::$container as non
static AppTestsControllerWebhookControllerTest::$container in
C:UsersuserDesktopStripeFormation2testsControllerWebhookControllerTest.php
on line 11

I made this :

<?php
namespace AppTestsController;

use DateTime;
use AppEntityUser;
use AppEntitySubscription;
use DoctrineORMEntityManagerInterface;
use SymfonyBundleFrameworkBundleTestWebTestCase;
use SymfonyComponentSecurityCoreEncoderUserPasswordEncoderInterface;

class WebhookControllerTest extends WebTestCase
{
    /** @var EntityManagerInterface */
    private $em;
    private $container;

    public function setUp()
    {
        self::bootKernel();
        $this->container = self::$kernel->getContainer();
        $this->em = $this->container->get('doctrine')->getManager();
    }
    // ...

Can someone help me please ?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *