How to set global value before running PHPUnit skeleton

We set the global in our preend file, which is used to form the path for require_once calls. For example:

require_once($GLOBALS['root'].'/library/particleboard/JsonUtil.php');

The problem is that when you run the PHPUnit skeleton test builder, the preend file does not start, so the global one is never installed. When i started

cd /company/trunk/queue/process; phpunit --skeleton-test QueueProcessView

PHPUnit tries to enable require_once in QueueProcessView, but since $ GLOBALS ['root'] is never set, I get a fatal error when including the required file.

For example, for PHPUnit, what should be

require_once(/code/trunk/library/particleboard/JsonUtil.php)

resolved as

require_once(/library/particleboard/JsonUtil.php)

Pay attention to the missing root.

Does anyone know if the skeleton test code has any way to invoke a PHP file before it runs? In this, I could set my GLOBAL ['root'] in this file.

.

+3
2

, ,

phpunit --bootstrap prepend.php --skeleton-test QueueProcessView

:

test.php:

<?php   
require_once($GLOBALS['root'].'/confirmedToRun.php');
class test
{
   function doStuff()
   {
   }
}

prepend.php:

<?php   
$root = "/tmp/";

confirmedToRun.php:

<?php   
echo __FILE__;

phpunit --bootstrap prepend.php --skeleton-test test , testTest.php - confirmedToRun.php.

phpunit --bootstrap prepend.php --skeleton-test test
PHPUnit 3.4.2 by Sebastian Bergmann.

/tmp/confirmedToRun.php
Wrote skeleton for "testTest" to "/home/me/tmp/testTest.php".
+2

, . PHPUnit/Util/Test.php, . , , .

0

Source: https://habr.com/ru/post/1719048/


All Articles