Run composer install from fresh git clone.
Run /libraries/vendor/bin/phpunit
PHPunit to run all tests through til the end
stops at test 61 with a $_SERVER['SCRIPT_NAME'] error
I suspect that the $_SERVER['SCRIPT_NAME'] is being cleared in one of the included Joomla required files for the PHPunit tests.
PHPunit output
➜ joomla-cms git:(phpunit) ✗ libraries/vendor/bin/phpunit
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS......SS 61 / 5834 ( 1%)
SSSSSSSSSSSSSSS.......SSSSSSSSSSSSSSSSSEUndefined index: SCRIPT_NAME
User deprecation notices (85)
JError::setErrorHandling() is deprecated: 84x
21x in JComponentRouterViewconfigurationTest::setUp
21x in JComponentRouterViewconfigurationTest::tearDown
12x in JComponentRouterLegacyTest::setUp
12x in JComponentRouterLegacyTest::tearDown
6x in JComponentRouterBaseTest::setUp
6x in JComponentRouterBaseTest::tearDown
3x in JComponentRouterRulesNomenuTest::setUp
3x in JComponentRouterRulesNomenuTest::tearDown
JApplication is deprecated: 1x
1x in JComponentRouterBaseTest::testConstruct
Labels |
Added:
?
|
Category | ⇒ | Libraries |
Status | New | ⇒ | Information Required |
No, I've done composer install and composer update both from a fresh git clone in a new branch called phpunit.
Can't reposduce the problem locally, please add "--testdox" to the phpunit call so we seen which test is falling. What's your PHP version and OS?
PHP 7.2 running on linux mint 18.2
I had an issue running PHPunit on PHP 7.1, one of the required libraries in the vendor directory threw an exception.
joomla-cms git:(phpunit) ✗ php --version
PHP 7.2.4-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Apr 5 2018 08:53:57) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.4-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
PHPunit with the --testdox option
joomla-cms git:(phpunit) ✗ libraries/vendor/bin/phpunit --testdox
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
JApplicationAdministrator
[ ] Get client id
[ ] Get name
[ ] Get menu
[ ] Get pathway
[ ] Get router
[ ] Get template
[ ] Is admin
[ ] Is site
[ ] Is client
[ ] Render
JApplicationCms
[ ] construct
[ ] constructDependancyInjection
[ ] Execute without document
[ ] Execute with document
[ ] Get
[ ] Get cfg
[ ] Get instance
[ ] Get menu
[ ] Get pathway
[ ] Get router
[ ] Get template
[ ] Is admin
[ ] Is site
[ ] Is client
[ ] Redirect
[ ] Redirect legacy
[ ] Redirect legacy with empty message and empty status
[ ] Redirect with headers sent
[ ] Redirect with javascript redirect
[ ] Redirect with moved
[ ] Redirect with url
[ ] Render
JApplicationSite
[ ] Get client id
[ ] Get name
[ ] Get menu
[ ] Get params
[ ] Get pathway
[ ] Get router
[ ] Get template
[ ] Is admin
[ ] Is site
[ ] Is client
[ ] Render
[ ] Set get detect browser
[ ] Set get language filter
[ ] Set template
JComponentHelper
[ ] Get component
[ ] GetComponent falseComponent
[ ] GetComponent falseComponent strict
[ ] Is enabled
[ ] Is installed
[ ] Get params
JComponentRouterBase
[x] Construct
[x] Preprocess
JComponentRouterLegacy
[x] Construct
[x] Preprocess
[x] Build
[x] Parse
JComponentRouterView
[ ] Register view
[ ] Get views
[ ] Get path
[ ] Get rules
[ ] Attach rules
[ ] Attach rule
[ ] Detach rule
[ ] Preprocess
[ ] Build
[ ] Parse
[ ] Get name
[ ] Get name exception
JComponentRouterViewconfiguration
[x] Construct
[x] Set name
[x] Set key
[x] Set parent
[x] Set nestable
[x] Add layout
[x] Remove layout
JComponentRouterRulesMenu
[ ] Construct
[ ] Preprocess
[ ] Preprocess language
[ ] Preprocess active
[ ] Preprocess layout
[ ] Build lookup
JComponentRouterRulesNomenu
Undefined index: SCRIPT_NAME
User deprecation notices (85)
JError::setErrorHandling() is deprecated: 84x
21x in JComponentRouterViewconfigurationTest::setUp
21x in JComponentRouterViewconfigurationTest::tearDown
12x in JComponentRouterLegacyTest::setUp
12x in JComponentRouterLegacyTest::tearDown
6x in JComponentRouterBaseTest::setUp
6x in JComponentRouterBaseTest::tearDown
3x in JComponentRouterRulesNomenuTest::setUp
3x in JComponentRouterRulesNomenuTest::tearDown
JApplication is deprecated: 1x
1x in JComponentRouterBaseTest::testConstruct
Do you have configuration.php
file created? Unit test does not require it.
There's no configuration.php, this is pretty much a fresh clone from the joomla-cms repo with a new branch called phpunit and then running the command composer install
I had the same in J3.x but I do not remember what I did to fix that.
Maybe you have some (untracked) files from other branch: 4.0-dev vs staging
I have cloned the joomla-cms main branch which seems to be staging. I haven't checked out any other branches or mixed this with another branch. Strictly followed these steps
git clone https://github.com/joomla/joomla-cms.git joomla-cms
cd joomla-cms
git checkout -b phpunit
composer install
libraries/vendor/bin/phpunit --testdox
Status | Information Required | ⇒ | Discussion |
I don't have a good idea besides using a debugger and finding out what is the problem.
@venomDeved can you try to execute a script that checks if $_SERVER['SCRIPT_NAME'] is defined in your setup? Maybe there is a problem in the server config that SCRIPT_NAME is not defined at all by the server. ;)
Maybe some php module is missing, ex: sqlite3, xml
So I made a quick die() debug in tests/unit/core/case/case.php
with 2 additional parts
This is a new function added to case.php taken from
libraries/vendor/phpunit/phpunit/src/framework/TestCase.php
public function __construct($name = null, array $data = array(), $dataName = '') {
parent::__construct($name, $data, $dataName);
echo "\$_SERVER:\n";
print_r($_SERVER);
}
and then this code is added to case.php in the setUp function
protected function setUp()
{
echo "\$_SERVER:\n";
print_r($_SERVER);
die();
$this->setExpectedError();
parent::setUp();
}
output for __construct()
$_SERVER:
...
[PHP_SELF] => libraries/vendor/bin/phpunit
[SCRIPT_NAME] => libraries/vendor/bin/phpunit
[SCRIPT_FILENAME] => libraries/vendor/bin/phpunit
[PATH_TRANSLATED] => libraries/vendor/bin/phpunit
...
output for setUp()
JComponentRouterBase
$_SERVER:
which means $_SERVER has been completely wiped out at some point
Finally i found the problem.
In my case was a missing php extension.
Is common to be missing sqlite3 and zip. In my case was on only php7.1-zip.
You can check your modules using this linux command.
dpkg --get-selections | grep php
Here are my php modules for php 7.1
php7.1-cli install
php7.1-common install
php7.1-curl install
php7.1-gd install
php7.1-intl deinstall
php7.1-json install
php7.1-ldap install
php7.1-mbstring install
php7.1-mcrypt install
php7.1-mysql install
php7.1-opcache install
php7.1-readline install
php7.1-soap deinstall
php7.1-sqlite3 install
php7.1-xml install
php7.1-zip install
sudo apt-get install php7.1-sqlite3 php7.1-zip to fix the problem ;)
Remember restart apache
Glad to hear you found the problem
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-06-04 08:13:55 |
Closed_By | ⇒ | brianteeman |
It would be good practice to inform you (Joomla should do that) which php extensions are required on starting unit tests.
Yep solved, thanks
I faced with the same problem.
$_SERVER variable is null at setUp().
Please, explain the way how to solve this problem.
You have to install or/and enable some missing php modules on your server, check if you have:
php-zip
php-xml
php-sqlite3
To see the list of enabled modules, you can run the php -m
command.
My installed php version contains a lot of optional modules:
[PHP Modules]
apcu
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
json
ldap
libxml
mbstring
mcrypt
memcached
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_dblib
pdo_mysql
pdo_pgsql
pdo_sqlite
pdo_sqlsrv
pgsql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
sqlsrv
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
Yes, my PHP modules have the followings: by "php -m"
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mhash
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
readline
Reflection
session
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
zip
zlib
@byungwook-kim Did you solve the problem?
Not yet.
I can't find a way to solve the problem.
@venomDeved Could you explain how to solve this problem?
Installing the sqlite3 module worked for me.
What version of PHP are you using?
Are you also using the PHPUnit file in the libraries/vendor/bin folder?
@venomDeved
In my case, the sqlite3 module is already installed on PHP version 5.6.31
I didn't install the PHPUnit on libraries/vendor/bin folder.
It's needed to install the PHPUnit on libraries/vendor/bin folder ?
I think you might need PHP v7 but yeah definitely run composer install and use the libraries/vendor/bin/PHPUnit for testing
@venomDeved
I installed PHP v7 (7.1.9) and libraries/vendor/bin/PHPUnit using composer.
But the above issue was not solved.
Are all the modules now installed for PHP v7?
And is PHP v7 your default run version?
Sure, I checked already some PHP functions for version 7.
for "php --version " displayed as following:
PHP 7.1.19 (cli) (built: Jun 21 2018 07:32:04) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
Does it work with
composer install
?