I have bee trying to get this test to run
require_once 'PHPUnit/Framework.php';
require_once('../config/config.php');
require_once('../classes/division.class.php');
class DivisionTest extends PHPUnit_Framework_TestCase
{
public function Divisiontest()
{
$division = new division();
try{
$division->createDivisionDetails();
}catch (CustomException $e) {
return;
}
$this->fail('An expected exception has not been raised.');
}
}
on this Command
phpunit --configuration=phpunit.xml division.test.php
but keep geting the error message
PHP Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 13
Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 13
PHP Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 26
Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 26
PHP Warning: require_once(/people_scope/config/standard.inc.php): failed to open stream: No such file or directory in /home/workspace/people_scope/config/config.php on line 46
Warning: require_once(/people_scope/config/standard.inc.php): failed to open stream: No such file or directory in /home/workspace/people_scope/config/config.php on line 46
PHP Fatal error: require_once(): Failed opening required '/people_scope/config/standard.inc.php' (include_path='/usr/bin:.:/usr/share/php:/usr/share/pear:/people_scope/assets/PEAR/:/people_scope/classes/base/') in /home/workspace/people_scope/config/config.php on line 46
Fatal error: require_once(): Failed opening required '/people_scope/config/standard.inc.php' (include_path='/usr/bin:.:/usr/share/php:/usr/share/pear:/people_scope/assets/PEAR/:/people_scope/classes/base/') in /home/workspace/people_scope/config/config.php on line 46
I am using a phpunit.xml to try to set the $_SERVER['HTTP_HOST'] but seem like it is not working at all
<?xml version="1.0" encoding="utf-8" ?>
<phpunit>
<php>
<server name="HTTP_HOST" value="DEV"/>
</php>
</phpunit>
Everything I have read seem to say this should work
The xml looks fine as far as i can see it. Two suggestions:
class DivisionTest extends PHPUnit_Framework_TestCase
{
public function Divisiontest()
i'd change the function name to testDivision() so phpunit picks it up as a real test (the code gets execution because its named like the class (a.k.a. php 4 style constructor) but thats not really optimal)
If that doesn't fix your problem: Does it work when you put
$_SERVER['HTTP_HOST'] = "DEV";
before the
$division = new division();
statement ? Just to make sure the error is that the xml file isn't read and doesn't hide somewhere else
Related
I am working with prestashop 1.7
i deleleted the cache folder but i restored it, and i have the same problem
Fatal error: Uncaught Error: Class 'Cache' not found in \prestashop\classes\ObjectModel.php on line 2000
idon't have the "class_index.php" file in cache folder. I don't have Cache.php in classes folder
any suggestion please
Probably you are missing some core file,
yhe same thing happened to me in the past, when transferring with rsync the site from one server to another I excluded "cache" thinking to bypass the only cache folder, but I also excluded some core files :)
Check for the existance of the /classes/cache folder,
it should contain "Cache.php" and some other Cache related classes aswell.
If they are missing, restore them from a backup or from the official Prestashop archive of the same version.
i have these warning
Warning: simplexml_load_file(): I/O warning : failed to load external entity "" in /home/vrqlcrq/www/src/Core/Localization/CLDR/Reader.php on line 152
Warning: simplexml_load_file(): I/O warning : failed to load external entity "" in /home/vrqlcrq/www/src/Core/Localization/CLDR/Reader.php on line 162
Notice: Trying to get property 'parentLocales' of non-object in /home/vrqlcrq/www/src/Core/Localization/CLDR/Reader.php on line 212
Notice: Trying to get property 'parentLocale' of non-object in /home/vrqlcrq/www/src/Core/Localization/CLDR/Reader.php on line 212
Warning: Invalid argument supplied for foreach() in /home/vrqlcrq/www/src/Core/Localization/CLDR/Reader.php on line 212
Notice: Trying to get property 'parentLocales' of non-object in /home/vrqlcrq/www/src/Core/Localization/CLDR/Reader.php on line 212
Notice: Trying to get property 'parentLocale' of non-object in /home/vrqlcrq/www/src/Core/Localization/CLDR/Reader.php on line 212
Warning: Invalid argument supplied for foreach() in /home/vrqlcrq/www/src/Core/Localization/CLDR/Reader.php on line 212
I'm at my first steps in PHP and i'm trying to import a file with some functions but it is not working.
I tryed to use include, include_once, require. function.php is in the same directory.
<?php
include 'function.php';
$accounts = [ ... ];
$accounts['123.456.789-10'] = withdraw(
$accounts['123.456.789-10'],
500
);
function withdraw is in function.php file.
Warning: include(function.php): failed to open stream: No such file or
directory in banco.php on line 2
Warning: include(): Failed opening 'function.php' for inclusion
(include_path='.;C:\php\pear') in banco.php on line 2
Fatal error: Uncaught Error: Call to undefined function sacar() in
banco.php:19 Stack trace:
0 {main} thrown in banco.php on line 19
check the permissions of the file you are including and the state of letters capital or small every thing must be the same
I have to run a php file every 5 seconds , and have two issues
1. The file works perfectly when opened in a browser, but running the 'php myfile.php' command fails and produces the following error
PHP Warning: include_once(../tutadmin/config/config.php): failed to open stream: No such file or directory in /var/www/html/cron/teacher_status_cron.php on line 3
PHP Warning: include_once(): Failed opening '../tutadmin/config/config.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/cron/teacher_status_cron.php on line 3
PHP Notice: Use of undefined constant TBL_USER - assumed 'TBL_USER' in /var/www/html/cron/teacher_status_cron.php on line 5
PHP Notice: Use of undefined constant TEACHER_USER_GROUP_ID - assumed 'TEACHER_USER_GROUP_ID' in /var/www/html/cron/teacher_status_cron.php on line 9
PHP Notice: Undefined variable: current_user_id in /var/www/html/cron/teacher_status_cron.php on line 14
PHP Notice: Undefined variable: current_date_time in /var/www/html/cron/teacher_status_cron.php on line 15
PHP Notice: Undefined variable: dbc in /var/www/html/cron/teacher_status_cron.php on line 20
PHP Fatal error: Uncaught Error: Call to a member function Query() on null in /var/www/html/cron/teacher_status_cron.php:20
Stack trace:
#0 {main}
thrown in /var/www/html/cron/teacher_status_cron.php on line 20
Crontab will not run the program every 5 seconds, only every minute at best.
Edit: the file does not work outside of cron in the CLI either, only on a web browser.. Cron is not the issue.
Because you have not right permissions on file, your cron can not open file, change permissions.
I know ideally that I should fix all the places in my code where PHP Notices are being thrown but for now I am trying to get a simple test up and running for one part of the application.
When I try to run my test using
sudo phpunit -c tests/phpunit.xml tests/
I get the following notices:
PHP Notice: Undefined property: stdClass::$integer_value in /var/www/application/authenticate.php on line 111
PHP Notice: Undefined property: stdClass::$boolean_value in /var/www/application/authenticate.php on line 115
PHP Notice: Undefined property: stdClass::$boolean_value in /var/www/application/site/authenticate.php on line 115
PHP Notice: Undefined property: stdClass::$integer_value in /var/www/application/authenticate.php on line 111
I've tried following the advice on this answer to a similar question https://stackoverflow.com/a/8412996/3263538
and have created a phpunit.xml configuration file which includes the following xml to ignore notices and warnings
tests/phpunit.xml
<phpunit convertErrorsToExceptions="false"
convertNoticesToExceptions="false"
convertWarningEToExceptions="false">
</phpunit>
UtilitesTest.php (dummy test that returns true)
<?php
use PHPUnit\Framework\TestCase;
include_once "/var/www/application/utilities.php";
class UtilitiesTest extends TestCase
{
public function testEmpty()
{
return 1;
}
}
?>
but still no luck. Is there something I'm missing here? Ideally I'd like to suppress these Notice messages.
I created a config file that has a variable I want to use as a constant.
<?php
$ROOT_PATH = 'C:/Users/me/Documents/app-qas.com/site';
?>
On a CLASS page where I want to use the variable I added the following before instantiating the CLASS:
include_once("config.php");
$root=$ROOT_PATH;
I made the appropriate scoping changes to the functions in my class as follows:
global $root;
include_once($root."/Library/API/database.inc.php");
When I run my app, it DOES perform all of the data connections it
is designed to do, BUT it STILL returns the following errors:
Warning: include_once(config.php): failed to open stream: No such file
or directory in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 5
Warning: include_once(): Failed opening 'config.php' for inclusion
(include_path='.;C:\php\pear') in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 5
Notice: Undefined variable: ROOT_PATH in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 6
Warning: include_once(/Library/API/database.inc.php): failed to open
stream: No such file or directory in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 112
Warning: include_once(): Failed opening
'/Library/API/database.inc.php' for inclusion
(include_path='.;C:\php\pear') in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 112
Warning: include_once(/Library/API/database.inc.php): failed to open
stream: No such file or directory in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 112
Warning: include_once(): Failed opening
'/Library/API/database.inc.php' for inclusion
(include_path='.;C:\php\pear') in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 112
If I comment out the include and hard code the $root it runs like before BUT it DOES NOT throw any errors:
#include_once("joblaunch.php");
#$root=$ROOT_PATH;
$root='C:/Users/me/Documents/app-qas.com/site';
I don't understand why it runs and throws errors when getting the variable from the config.php but runs and doesn't throw an error when hard coding the path.
if you define a constant instead of a variable, this problem should be solved,
definition
old:
$ROOT_PATH = 'C:/Users/me/Documents/app-qas.com/site';
new:
define('ROOT_PATH', 'C:/Users/me/Documents/app-qas.com/site');
usage
old:
$root=$ROOT_PATH;
new:
$root = ROOT_PATH;