Set extensions directory for tests

Notice: This thread is very old.
amik
Member | 118
+
0
-

Hi,
I'm just thinking about how to set extension directory for PHP in ini files for tests. When I use custom php.ini for my tests, it looks for extensions in C:\PHP\ext (probably default), which is wrong in my case.

Putting my local absolute path to PHP extensions into test ini files seems as total nonsense for me, is there any other way to specify extension path for tests? How do you solve this?

Thanks.

Milo
Nette Core | 1283
+
0
-

I don't know about universal solution. Any computer can have a different environment. Two solutions I'm using:

1)

  • distribute INI file as a php.example.ini with empty extensions_dir=
  • copy it as php.ini on specific PC, edit the path in it
  • add it into .git/info/exclude to ignore it

2)

  • call Tester as tester -c tests/php.ini -d extension_dir=/path/to/ext tests
amik
Member | 118
+
0
-

Thanks for answer @Milo , I assume that this is a bit pain always then. I finally figured out this solution, most suitable for me (.sh script to run tests, lets me have custom php.ini and extract extension_dir from PHP CLI's php.ini without need of manual edits):

	cp ./tests/php-unix.ini ./tests/php.ini # php.ini is ignored
	PHP_EXT=`php -r "echo ini_get('extension_dir');"`
	echo "" >> ./tests/php.ini # ensure newline at the end
	echo "extension_dir=$PHP_EXT" >> ./tests/php.ini

	./libs/composer/bin/tester ./tests -p php -c ./tests

Last edited by amik (2015-09-30 08:52)

Milo
Nette Core | 1283
+
0
-

Good idea with ini_get(). I don't feel it as a pain, because I maintain repo on 5 places at max and this is an one-off setting.