msalsas / symfony-bundle-skeleton

The "Symfony Bundle Skeleton" is an application to create reusable Symfony bundles.
MIT License
9 stars 3 forks source link

Found errors running acme tests #1

Closed filipefernandes007 closed 4 years ago

filipefernandes007 commented 4 years ago

After running acme tests:

Acme\FooBundle\Tests\ServiceTest::testFooWithIntegers
TypeError: Argument 2 passed to Acme\FooBundle\Service\Service::__construct() must be an instance of Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface, null given, called in /var/www/symfony-bundle-skeleton/lib/acme/foo-bundle/Tests/ServiceTest.php on line 63

/var/www/symfony-bundle-skeleton/lib/acme/foo-bundle/Service/Service.php:50
/var/www/symfony-bundle-skeleton/lib/acme/foo-bundle/Tests/ServiceTest.php:63

You should call setUp like this to avoid that error:

public function setUp(): void
    {
        parent::setUp();
        $this->setDefaultMocks();
        $this->setUserMocks(); // <----
        $this->translator = new Translator('en');
    }

Also, after that fix, you have this error:

1) Acme\FooBundle\Tests\ServiceTest::testFooWithIntegers
Trying to configure method "getUser" which cannot be configured because it does not exist, has not been specified, is final, or is static

In fact, what you may want is this:

...
#use Prophecy\Argument\Token\TokenInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
...

Finally, you have this assertion error:

1) Acme\FooBundle\Tests\ServiceTest::testFooWithIntegers
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'This is an uncertain  output'
+'This is an uncertain b output 39.083333333333'

/var/www/symfony-bundle-skeleton/lib/acme/foo-bundle/Tests/ServiceTest.php:69

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

Another subject. Running twice the command leads to this:

In CreateBundleCommand.php line 766:

  Warning: file_get_contents(/var/www/symfony-bundle-skeleton/config/packages/acme_foo.yaml): failed to open stream: No such file or directory  

Keep going on your good work.

msalsas commented 4 years ago

Thank you @filipefernandes007, I've just fixed the issues. The assertion error is made on purpose, so that you have a starting point to write your tests and services. Tests should be only executed after the bundle creation, then you shouldn't have errors such as files not found