473,387 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Accessing variables defined in unit testcase file in src file using phing

I have defined some variables in my test file then i call a function from my test file to src file and verify the result. While using phing it is not working, but if i use php or phpunit to verify it is working fine.

Example: add.php (source file) (present in the src directory)
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function add_two_numbers()
  3. {
  4.     global $a,$b; /* defined in test file*/
  5.     return ($a + $b);
  6. }
  7. ?>
  8.  
Other file:

// add_Test (Test File) (present in the test directory)
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $a = 5;
  3. $b = 3;
  4. require_once ("__DIR__./../src/add.php");
  5.  
  6. class add_Test extends PHPUnit_Framework_TestCase{
  7.     function testadd()
  8.     {
  9.         $act = 8;
  10.         $res = add_two_numbers();
  11.         $this -> assertTrue($res === $act);
  12.     }
  13. }
  14.  
  15. ?>
  16.  
Now, if i use phpunit then it is working file but with phing the global variables are not set. Please tell me a solution to this.
Mar 3 '13 #1
0 1280

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ronnie Laurikkala | last post by:
In e.g. a Bourne shell script I can source variables and values; #!/bin/sh .. ${HOME}/script_common_lib How can I source variables and values from a file and use them in Perl-scripts? ...
8
by: scott | last post by:
hi, sorry if this has been adressed some where elss. if it has plz can you point me to it and ill go read it. any way, i want to declare some variables with in a header file. lets say int i; ...
1
by: Nathan | last post by:
Hi, I have created a class library creating a number of forms and a few public variables. I have a project that references the .dll for this class library, and in that project I need to access...
12
by: jeniffer | last post by:
Can a static function defined in a C file be ever referred (called) externally from another C file?If so in which conditions?
1
by: christian.Blackburn | last post by:
Hi Gang, On my development system I am not getting this error, but it does happen when I upload it to my ISP. Can someone tell me why this is happening? I don't have any user-defined controls...
1
by: Larry Epn | last post by:
I've created a project from Microsoft's "club.vsi". I don't want inline code so I've separated all aspx and ascx pages into code-behind pages. I'm compiling the project and continue to get this...
2
by: howa | last post by:
e.g. $a = 1; $b = 2; i want to get all the variables defined in the current scope, is it possible? thanks...
2
by: Jurek Dabrowski | last post by:
hi all, I have a question in reference to accessing variables in another class maybe someone has dealt with before. I have some public variables declared in my main plug-in class...
0
by: murl | last post by:
I want to create a web user control with a base class of 'GridView' so I can wrap the needed methods to make rows clickable. However when building the project I get the following message: "Make...
2
by: murthydb2 | last post by:
Can someone help me to find a solution for the below error . Problem Description: I have a User-defined function which is written using an external C program file . When this UDF is called the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.