developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 8 years ago

Closed 8 years ago

#1480 closed bug (fixed)

PHPUnit Error when using runtests.php

Reported by: remib33 Owned by: laurentj
Priority: normal Milestone: Jelix 1.3.3
Component: jelix Version: 1.3.2
Severity: normal Keywords: phpunit
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version: 5.3

Description (last modified by laurentj)

When a unit-tested class contains the following Jelix instruction: jclasses::inc, then there is an error when launching Jelix runtests.php

     [exec] PHP Notice:  Trying to get property of non-object in /home/user/projet/workspace_php/lib/jelix/core/selector/jSelectorLoc.class.php on line 41
     [exec] PHP Notice:  Trying to get property of non-object in /home/user/projet/workspace_php/lib/jelix/core/selector/jSelectorLoc.class.php on line 44
     [exec] PHP Fatal error:  Uncaught exception 'jExceptionSelector' with message 'jelix module is not enabled !!' in /home/user/projet/workspace_php/lib/jelix/core/selector/jSelectorClass.class.php:62
     [exec] Stack trace:
     [exec] #0 /home/user/projet/workspace_php/lib/jelix/core/selector/jSelectorClass.class.php(52): jSelectorClass->_createPath()
     [exec] #1 /home/user/projet/workspace_php/lib/jelix/utils/jClasses.class.php(129): jSelectorClass->__construct('m2m~ws/account/...')
     [exec] #2 /home/user/projet/workspace_php/m2m/modules/m2m/tests/AccountSummary.pu.php(3): jClasses::inc('m2m~ws/account/...')
     [exec] #3 /usr/share/php/PHPUnit/Util/Fileloader.php(95): include_once('/home/user/pr...')
     [exec] #4 /usr/share/php/PHPUnit/Util/Fileloader.php(79): PHPUnit_Util_Fileloader::load('/home/user/pr...')
     [exec] #5 /usr/share/php/PHPUnit/Framework/TestSuite.php(358): PHPUnit_Util_Fileloader::checkAndLoad('/home/user/pr...')
     [exec] #6 /usr/share/php/PHPUnit/Framewo in /home/user/projet/workspace_php/lib/jelix/core/selector/jSelectorClass.class.php on line 62

The direct cause of this is that $gJconfig global var is not properly initialized.

Actually, during PHPUnit addTestFile method call (performed by Jelix), jelix is not properly initialized and jclasses::inc framework instruction is not recognized in AccountSummary? unit tested class.

I propose to perform the following modification in command.php Jelix script: Instantiate JCoordinator class before the existing following code (instead of after in current code)

		// it will initialize global variables $gJCoord $gJConfig. it could be needed by tests
        $coord = new jCoordinator($this->epInfo->configFile, false); // NOW BEFORE THE FOLLOWING CODE:

        if ($modulesTests == 0) {
            // we add all modules in the test list
            $suite = $this->getAllModulesTestSuites();
            if (count($suite)) {
                $this->arguments['test'] = $suite;
                unset ($this->arguments['testFile']);
            }
            else {
                $this->showMessage("Error: no tests in modules\n");
                exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
            }
        }
       

Change History (5)

comment:1 Changed 8 years ago by remib33

  • Version changed from 1.3.2 to 1.3.1

comment:2 Changed 8 years ago by remib33

  • Version changed from 1.3.1 to 1.3.2

comment:3 Changed 8 years ago by laurentj

  • Description modified (diff)

comment:4 Changed 8 years ago by laurentj

  • Description modified (diff)
  • Milestone set to Jelix 1.3.3
  • Owner set to laurentj
  • Status changed from new to assigned

comment:5 Changed 8 years ago by laurentj

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.