Usually you are using mocks as a replacement for external dependencies for your class under test. In this case you just want to test the real behaviour of the class, and you are not dealing with any dependencies for the class Foo
. In this case there is really no need to mock, I would just define a concrete instance of the abstract class for testing purposes.
That said, you can refactor to something like this.
class ConcreteFoo extends Foo
{
}
class ExampleTest extends PHPUnit_Framework_TestCase
{
public function testDefaultsAreAssignedToData()
{
$expected = ['foo' => 'bar'];
$foo = new ConcreteFoo($expected);
$this->assertEquals($expected, $foo->getData());
}
}