<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Unit Testing with NetBeans and phpUnit</title>
	<atom:link href="http://www.logaans-site.co.uk/2008/11/12/unit-testing-with-netbeans-and-phpunit/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.logaans-site.co.uk/2008/11/12/unit-testing-with-netbeans-and-phpunit/</link>
	<description>In my own little world, world...world</description>
	<lastBuildDate>Wed, 03 Aug 2011 08:52:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Logaan</title>
		<link>http://www.logaans-site.co.uk/2008/11/12/unit-testing-with-netbeans-and-phpunit/comment-page-1/#comment-29</link>
		<dc:creator>Logaan</dc:creator>
		<pubDate>Sat, 21 Feb 2009 17:19:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=174#comment-29</guid>
		<description>Actually I did something very similar but I used reflection.

I created an empty interface called ITestable, which I implemented on all my tests.

The test file that I passed to phpUnit included all php files from my test folder.

Using reflection I found all the classes that implemented that interface and added them to the test suite that way.</description>
		<content:encoded><![CDATA[<p>Actually I did something very similar but I used reflection.</p>
<p>I created an empty interface called ITestable, which I implemented on all my tests.</p>
<p>The test file that I passed to phpUnit included all php files from my test folder.</p>
<p>Using reflection I found all the classes that implemented that interface and added them to the test suite that way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://www.logaans-site.co.uk/2008/11/12/unit-testing-with-netbeans-and-phpunit/comment-page-1/#comment-27</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Fri, 20 Feb 2009 22:18:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=174#comment-27</guid>
		<description>This script automatically finds and runs test files (which end in &quot;Test&quot;) in it&#039;s same directory.  Set it as the index of a separate test project.

In Netbeans configuration, set &quot;Run As&quot; to &quot;Script&quot; and arguments as &quot;[whatever flags you want to send phpunit] AllTests [name of script file below]&quot;

e.g. &quot;--verbose AllTests main.php&quot; (no quotes)

addTestFile(&#039;MySqlSessionHandlerTest.php&#039;);
		//$suite-&gt;addTestFile(&#039;PageProtectorTest.php&#039;);

		// Automatically add all php files ending in &quot;Test&quot; to the suite
		//

		// Make an array of the file names in this script&#039;s directory
		$testProjectFiles = scandir(dirname(__FILE__));

		// Seach the array for test files
		foreach ($testProjectFiles as $file) {

		  //Get the end of the file name for comparison
		  $lastEightOfFileName = substr($file, -8);

		  // Add file to suite if it&#039;s a test file
		  if ($lastEightOfFileName == &quot;Test.php&quot;) {
			$suite-&gt;addTestFile($file);
		  };
		}


        return $suite;
    }
}

require_once &#039;/path/to/phpunit&#039;;

?&gt;</description>
		<content:encoded><![CDATA[<p>This script automatically finds and runs test files (which end in &#8220;Test&#8221;) in it&#8217;s same directory.  Set it as the index of a separate test project.</p>
<p>In Netbeans configuration, set &#8220;Run As&#8221; to &#8220;Script&#8221; and arguments as &#8220;[whatever flags you want to send phpunit] AllTests [name of script file below]&#8221;</p>
<p>e.g. &#8220;&#8211;verbose AllTests main.php&#8221; (no quotes)</p>
<p>addTestFile(&#8216;MySqlSessionHandlerTest.php&#8217;);<br />
		//$suite-&gt;addTestFile(&#8216;PageProtectorTest.php&#8217;);</p>
<p>		// Automatically add all php files ending in &#8220;Test&#8221; to the suite<br />
		//</p>
<p>		// Make an array of the file names in this script&#8217;s directory<br />
		$testProjectFiles = scandir(dirname(__FILE__));</p>
<p>		// Seach the array for test files<br />
		foreach ($testProjectFiles as $file) {</p>
<p>		  //Get the end of the file name for comparison<br />
		  $lastEightOfFileName = substr($file, -8);</p>
<p>		  // Add file to suite if it&#8217;s a test file<br />
		  if ($lastEightOfFileName == &#8220;Test.php&#8221;) {<br />
			$suite-&gt;addTestFile($file);<br />
		  };<br />
		}</p>
<p>        return $suite;<br />
    }<br />
}</p>
<p>require_once &#8216;/path/to/phpunit&#8217;;</p>
<p>?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: saetlan</title>
		<link>http://www.logaans-site.co.uk/2008/11/12/unit-testing-with-netbeans-and-phpunit/comment-page-1/#comment-20</link>
		<dc:creator>saetlan</dc:creator>
		<pubDate>Thu, 11 Dec 2008 12:06:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=174#comment-20</guid>
		<description>Your are right, I use linux, and it is a little bit different. With your script, I saw the server variables and the first argument has to be the path to your phpunit bin. The rest of the arguments as normal.

Here is the equivalent linux script:



Thank you very much for your help</description>
		<content:encoded><![CDATA[<p>Your are right, I use linux, and it is a little bit different. With your script, I saw the server variables and the first argument has to be the path to your phpunit bin. The rest of the arguments as normal.</p>
<p>Here is the equivalent linux script:</p>
<p>Thank you very much for your help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Logaan</title>
		<link>http://www.logaans-site.co.uk/2008/11/12/unit-testing-with-netbeans-and-phpunit/comment-page-1/#comment-19</link>
		<dc:creator>Logaan</dc:creator>
		<pubDate>Wed, 10 Dec 2008 18:48:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=174#comment-19</guid>
		<description>That array basically contains the arguments that are passed to phpunit on the command line (essentially phpunit is a batch script running a php script).

I discovered this by basically doing some digging, I looked at the phpunit batch script:

&lt;code&gt;set PHPBIN=&quot;E:\xampp\php\.\php.exe&quot;
&quot;E:\xampp\php\.\php.exe&quot; -d safe_mode=Off &quot;E:\xampp\php\pear/PHPUnit/TextUI/Command.php&quot; %*&lt;/code&gt;

From that you can see it just calls php with the &lt;em&gt;TextUI/Command.php&lt;/em&gt; script and passes it all the arguments (thats &lt;code&gt;%*&lt;/code&gt;)

Now I use Windows, so if you are using Linux there might be some extra work you have to do to get this to work.


The args above is the equivilant to:

&lt;code&gt;phpunit TestRunner.php --coverage-html &quot;D:\Logaan\Documents\XamppData\htdocs\FormManager\CodeCoverage&quot; --verbose &quot;D:\Logaan\Documents\XamppData\htdocs\FormManager\tests\TestSuite.php&quot;&lt;/code&gt;

(TestRunner.php is the name of the file with the code above)

If you write a simple test case that will print the server enviroment variables to the output, like:

&lt;code&gt;&lt;?php
error_reporting(E_ALL &#124; E_STRICT);
date_default_timezone_set(&#039;UTC&#039;);

require_once &#039;PHPUnit/Framework.php&#039;;

class DeleteModeTests extends PHPUnit_Framework_TestCase
{
	public function testExampleTest()
	{
		print_r($_SERVER);
	}
}


?&gt;&lt;/code&gt;
Then call it with phpUnit on the command line:

&lt;code&gt;phpunit example.php&lt;/code&gt;

And look at the server args:

&lt;code&gt;.
.
.

[argv] =&gt; Array
    (
        [0] =&gt; E:\xampp\php\pear/PHPUnit/TextUI/Command.php
        [1] =&gt; example.php
    )

[argc] =&gt; 2

.
.
.
.&lt;/code&gt;


That is how I discovered how to structure my arguments.


Essentially what you need to achieve is replicating the behaviour of the batch file. 
So that means pretending to have arguments being passed, invoke the &lt;em&gt;PHPUnit/TextUI/Command.php&lt;/em&gt; script and then excluding this file from code coverage (if thats important to you)

(Typing &lt;code&gt;phpunit--help&lt;/code&gt; will provide a list of available parameters, just have play with the example script and the arguments to see what results you need to achieve)


I hope this helps.</description>
		<content:encoded><![CDATA[<p>That array basically contains the arguments that are passed to phpunit on the command line (essentially phpunit is a batch script running a php script).</p>
<p>I discovered this by basically doing some digging, I looked at the phpunit batch script:</p>
<p><code>set PHPBIN="E:\xampp\php\.\php.exe"<br />
"E:\xampp\php\.\php.exe" -d safe_mode=Off "E:\xampp\php\pear/PHPUnit/TextUI/Command.php" %*</code></p>
<p>From that you can see it just calls php with the <em>TextUI/Command.php</em> script and passes it all the arguments (thats <code>%*</code>)</p>
<p>Now I use Windows, so if you are using Linux there might be some extra work you have to do to get this to work.</p>
<p>The args above is the equivilant to:</p>
<p><code>phpunit TestRunner.php --coverage-html "D:\Logaan\Documents\XamppData\htdocs\FormManager\CodeCoverage" --verbose "D:\Logaan\Documents\XamppData\htdocs\FormManager\tests\TestSuite.php"</code></p>
<p>(TestRunner.php is the name of the file with the code above)</p>
<p>If you write a simple test case that will print the server enviroment variables to the output, like:</p>
<p><code>< ?php<br />
error_reporting(E_ALL | E_STRICT);<br />
date_default_timezone_set('UTC');</p>
<p>require_once 'PHPUnit/Framework.php';</p>
<p>class DeleteModeTests extends PHPUnit_Framework_TestCase<br />
{<br />
	public function testExampleTest()<br />
	{<br />
		print_r($_SERVER);<br />
	}<br />
}</p>
<p>?></code><br />
Then call it with phpUnit on the command line:</p>
<p><code>phpunit example.php</code></p>
<p>And look at the server args:</p>
<p><code>.<br />
.<br />
.</p>
<p>[argv] => Array<br />
    (<br />
        [0] => E:\xampp\php\pear/PHPUnit/TextUI/Command.php<br />
        [1] => example.php<br />
    )</p>
<p>[argc] => 2</p>
<p>.<br />
.<br />
.<br />
.</code></p>
<p>That is how I discovered how to structure my arguments.</p>
<p>Essentially what you need to achieve is replicating the behaviour of the batch file.<br />
So that means pretending to have arguments being passed, invoke the <em>PHPUnit/TextUI/Command.php</em> script and then excluding this file from code coverage (if thats important to you)</p>
<p>(Typing <code>phpunit--help</code> will provide a list of available parameters, just have play with the example script and the arguments to see what results you need to achieve)</p>
<p>I hope this helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: saetlan</title>
		<link>http://www.logaans-site.co.uk/2008/11/12/unit-testing-with-netbeans-and-phpunit/comment-page-1/#comment-18</link>
		<dc:creator>saetlan</dc:creator>
		<pubDate>Wed, 10 Dec 2008 00:31:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=174#comment-18</guid>
		<description>hello, I am trying to debug de phpUnit test with your method, but I don&#039;t understand why your are filling the array with that data. 

Which phpUnit command matches your script? 

I have tried some ways to fill the array with a simple comand like,

phpunit anyFile.php --coverage-html

but I have not been successful.

thanks</description>
		<content:encoded><![CDATA[<p>hello, I am trying to debug de phpUnit test with your method, but I don&#8217;t understand why your are filling the array with that data. </p>
<p>Which phpUnit command matches your script? </p>
<p>I have tried some ways to fill the array with a simple comand like,</p>
<p>phpunit anyFile.php &#8211;coverage-html</p>
<p>but I have not been successful.</p>
<p>thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>

