sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Directory path error in BaseMenuTest #3766

Closed ghost closed 8 years ago

ghost commented 8 years ago
Question Answer
Bundle version dev-master 02478b4
Symfony version v2.8.5
php version PHP 5.6.21

Error message

When running the included tests i get

1) Sonata\AdminBundle\Tests\Menu\Integration\TabMenuTest::testLabelTranslationNominalCase
Twig_Error_Loader: The "/home/aaronm/Sites/devadmin/vendor/sonata-project/admin-bundle/Tests/Menu/Integration/../../../vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views" directory does not exist.

/home/aaronm/Sites/devadmin/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:94
/home/aaronm/Sites/devadmin/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:76
/home/aaronm/Sites/devadmin/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:34
/home/aaronm/Sites/devadmin/vendor/sonata-project/admin-bundle/Tests/Menu/Integration/BaseMenuTest.php:43

2) Sonata\AdminBundle\Tests\Menu\Integration\TabMenuTest::testLabelTranslationWithParameters
Twig_Error_Loader: The "/home/aaronm/Sites/devadmin/vendor/sonata-project/admin-bundle/Tests/Menu/Integration/../../../vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views" directory does not exist.

/home/aaronm/Sites/devadmin/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:94
/home/aaronm/Sites/devadmin/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:76
/home/aaronm/Sites/devadmin/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:34
/home/aaronm/Sites/devadmin/vendor/sonata-project/admin-bundle/Tests/Menu/Integration/BaseMenuTest.php:43

3) Sonata\AdminBundle\Tests\Menu\Integration\TabMenuTest::testLabelTranslationDomainOverride
Twig_Error_Loader: The "/home/aaronm/Sites/devadmin/vendor/sonata-project/admin-bundle/Tests/Menu/Integration/../../../vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views" directory does not exist.

/home/aaronm/Sites/devadmin/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:94
/home/aaronm/Sites/devadmin/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:76
/home/aaronm/Sites/devadmin/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:34
/home/aaronm/Sites/devadmin/vendor/sonata-project/admin-bundle/Tests/Menu/Integration/BaseMenuTest.php:43

Steps to reproduce

Run the included tests

Expected results

Tests should pass

Actual results

See error message

Suggested fix

Modify BaseMenuTest->setUp() to add array_filter and correct path for my installation type, as follows:

    public function setUp()
    {
        $twigPaths = array_filter(array(
            __DIR__.'/../../../vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views',
            __DIR__.'/../../../../../knplabs/knp-menu/src/Knp/Menu/Resources/views',
            __DIR__.'/../../../Resources/views',
        ), 'is_dir');
        $loader = new StubFilesystemLoader($twigPaths);
        $this->environment = new \Twig_Environment($loader, array('strict_variables' => true));
    }

This is similar to the technique used to solve the same problem in BaseWidgetTest.

Thank you!

greg0ire commented 8 years ago

It looks like you're trying to run the admin tests from a project. Why are you doing that?

ghost commented 8 years ago

Is that not intended? I got the idea looking at bin/qa_client_ci.sh in sonata-sandbox.

My thinking was that this would be a handy way to verify if something broke after updating dependencies. Am I barking up the wrong tree here? Apologies if so.

greg0ire commented 8 years ago

Is that not intended?

No, I don't think it is : when you get them, dependencies have already been tested, independently from each other. Also, some development dependencies that are necessary for testing might be missing. The sonata sandbox does run some unit tests, but I don't know why there would be a need for that : everything we merge passes tests.

greg0ire commented 8 years ago

But maybe I'm wrong and the sandbox test broke because of that…

OskarStark commented 8 years ago

But maybe I'm wrong and the sandbox test broke because of that…

you are right @greg0ire

greg0ire commented 8 years ago

Closing then