Skip to content

Instantly share code, notes, and snippets.

@jurchiks
Created September 25, 2019 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jurchiks/fd690dee6f7215a2eab1d90712463950 to your computer and use it in GitHub Desktop.
Save jurchiks/fd690dee6f7215a2eab1d90712463950 to your computer and use it in GitHub Desktop.
PHPUnit - broken public method calls in constructor
<?php
use PHPUnit\Framework\TestCase;
class ExceptionTestCase extends TestCase
{
public function testException()
{
$this->expectException(TypeError::class);
$this->expectExceptionMessage('call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object');
$this->getMockBuilder(Foo::class)
->enableProxyingToOriginalMethods()
->getMock();
}
}
class Foo
{
public function __construct()
{
$this->setBar();
}
public function setBar()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment