I have some var_dumps in my php code (i understand what there must be none in the end, but still), and while tests are running they outputs non necessary information to console, is there a method to ignore some code execution?
I've tried
/**
* @codeCoverageIgnore
*/
and
// @codeCoverageIgnoreStart
print '*';
// @codeCoverageIgnoreEnd
But this just ignores coverage, and still executes the code.
The assertEquals() function is a builtin function in PHPUnit and is used to assert whether the actual obtained value is equals to expected value or not. This assertion will return true in the case if the expected value is the same as the actual value else returns false.
PHPUnit provides methods that are used to automatically create objects that will replace the original object in our test. createMock($type) and getMockBuilder($type) methods are used to create mock object. The createMock method immediately returns a mock object of the specified type.
PHPUnit is a unit testing framework for the PHP programming language. It is an instance of the xUnit architecture for unit testing frameworks that originated with SUnit and became popular with JUnit.
You can set the setOutputCallback to a do nothing function. The effect is to suppress any output printed in the test or in the tested class.
As Example:
namespace Acme\DemoBundle\Tests;
class NoOutputTest extends \PHPUnit_Framework_TestCase {
public function testSuppressedOutput()
{
// Suppress output to console
$this->setOutputCallback(function() {});
print '*';
$this->assertFalse(false, "Don't see the *");
}
}
You can find some reference in the doc
Hope this help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With