Web lists-archives.com

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




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());
  }
}

?>