Error: Argument 1 passed to screenFake::__construct() must be an instance of databaseInterfaseFake, instance of Mock_databaseInterfaceFake_b36397fd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I am trying to write a unit test for a dependency injection situation and I have a reproducible example at the end.  I am getting this error:

1) testFake::test_fake
Argument 1 passed to screenFake::__construct() must be an instance of databaseInterfaseFake, instance of Mock_databaseInterfaceFake_b36397fd given, called in fakeTest.php on line 25 and de...

I have run across similar issues on the web, but they all point me to not mocking the correct object, which I do not think is the case here.  This is probably very obvious but I am brand new in using mocks and stubs so any help appreciated.

Thanks in advance,

<?php
class databaseInterfaceFake
{
  private $a;
  function __construct()
  {
    $a="a";
  }
}

class screenFake {
  private $db;
  function __construct(databaseInterfaseFake $dbFake) {
    $db = $dbFake;
  }
  function m() {
    return TRUE;
  }
}

class testFake extends PHPUnit_Framework_TestCase {
  public function test_fake() {
    $db = $this->getMock('databaseInterfaceFake');
    $screen = new screenFake($db);
    $this->assertTrue($screen->m());
  }
}

?>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux