Page 1 of 1

Missing argument 1 for PicturesTest::testAddition() in

Posted: Fri Nov 03, 2006 5:49 am
by kpraman

Code: Select all

<?php


  $pictureName=$_FILES['photo']['name'];
  $tmp_filename=$_FILES['photo']['tmp_name'];


  class PicturesTest extends PHPUnit_TestCase {
 
           function testAddition($pictureName)
                   {
                        echo $pictureName;
                    }

}

 $suite  = new PHPUnit_TestSuite('PicturesTest');
 $result = PHPUnit::run($suite);
 
 print $result->toHTML();

$new=new PicturesTest;

$new->testAddition($pictureName);

?>
I am getting error

Missing argument 1 for PicturesTest::testAddition()

Posted: Fri Nov 03, 2006 6:45 am
by Chris Corbyn
PHPUnit is trying to run the method because it starts with "test". PHPUnit does not pass arguments to test methods (why would it?).

What exactly are you trying to test?

Posted: Fri Nov 03, 2006 11:46 am
by aaronhall
It doesn't look like $pictureName is being set before you call testAddition()

Posted: Fri Nov 03, 2006 12:06 pm
by Chris Corbyn
aaronhall wrote:It doesn't look like $pictureName is being set before you call testAddition()
No, that's not the problem. Unit testing frameworks blindly run any methods which start with the name "test" such as "testFoo" "testing" etc etc. They don't pass arguments, they just run them. That's where the error comes from. Since the method is part of the test suite (i.e. it extends PHPUnit_TestCase) then it's being run automatically.

Posted: Fri Nov 03, 2006 12:29 pm
by aaronhall
Gotcha -- sorry to make you repeat yourself.

Posted: Mon Nov 06, 2006 1:01 am
by kpraman
I made a mistake,

function testAddition($pictureName)


No need of parameter.