Created
November 8, 2016 21:30
-
-
Save jeremyharris/99a0b59e8df57846a18de6f710f727c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CallbackCaller | |
{ | |
public function on($callback) | |
{ | |
// whoops doesn't fire, perhaps due to code error | |
} | |
} | |
class AssertionTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function testAssertionInCallback() | |
{ | |
$class = new CallbackCaller(); | |
$class->on(function() { | |
$this->assertTrue(false); | |
}); | |
$this->assertTrue(true); | |
} | |
} |
dogmatic69
commented
Nov 8, 2016
•
Right! This is a possible solution to the initial poorly written test.
Not sure any better ways, always done callback checks like that
your test should just be checking its called, nothing else. Should be a mocked callback that only sets the variable.
Another test should test what the callback actually does IRL
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment