Skip to content
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

LDAP Integration Tests fail due to autoloader #544

Closed
blizzz opened this issue Jul 24, 2016 · 4 comments
Closed

LDAP Integration Tests fail due to autoloader #544

blizzz opened this issue Jul 24, 2016 · 4 comments

Comments

@blizzz
Copy link
Member

blizzz commented Jul 24, 2016

For example, I want to run /apps/user_ldap/tests/IntegrationLib/IntegrationTestAccessGroupsMatchFilter.php the test will fail with:

PHP Fatal error:  Class 'OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest' not found in /srv/http/nextcloud/master/apps/user_ldap/tests/Integration/Lib/IntegrationTestAccessGroupsMatchFilter.php on line 31

I failed to figure out how the paths are constructed by the autoloader (as in have not seen where OCA stuff is registered as PSR-4 thingy):

[0] => /srv/http/nextcloud/master/apps/user_ldap/tests/integration/abstractintegrationtest.php
[1] => /srv/http/nextcloud/master/apps/user_ldap/lib/tests/integration/abstractintegrationtest.php

Anyway, to make the test run again, I need a line like

diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestAccessGroupsMatchFilter.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestAccessGroupsMatchFilter.php
index 4fcc833..ca89700 100644
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestAccessGroupsMatchFilter.php
+++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestAccessGroupsMatchFilter.php
@@ -23,11 +23,12 @@

 namespace OCA\User_LDAP\Tests\Integration\Lib;

-
 use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;

 require_once __DIR__  . '/../../../../../lib/base.php';

+\OC::$composerAutoloader->addPsr4('OCA\\User_LDAP\\Tests\\', \OC::$SERVERROOT . '/apps/user_ldap/tests/', true);
+
 class IntegrationTestAccessGroupsMatchFilter extends AbstractIntegrationTest {

    /**

in test file.

I am doubtful whether this is the best approach. Opinions, @rullzer @nickvergessen ?

@rullzer
Copy link
Member

rullzer commented Jul 25, 2016

Do you run the using phpunit directly?

If the app is enabled it should be allowed to autoload.

@blizzz
Copy link
Member Author

blizzz commented Jul 25, 2016

@rullzer not unit tests, nothing do with phpunit. Running directly from cli. App is enabled.

@nickvergessen
Copy link
Member

Tests is only registered in phpunit:

if (defined('PHPUNIT_RUN')) {
\OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
}

So you can also define('PHPUNIT', true);, or you use another constant and we add it there as well

@blizzz
Copy link
Member Author

blizzz commented Jul 25, 2016

@nickvergessen this helps, thx

MorrisJobke added a commit that referenced this issue Jul 25, 2016
fix autoloading in LPAP integration tests, resolves #544
MorrisJobke added a commit that referenced this issue Jul 27, 2016
[stable10] fix autoloading in LPAP integration tests, resolves #544
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants