PHP code example of namelesscoder / numerolog-phpunit
1. Go to this page and download the library: Download namelesscoder/numerolog-phpunit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namelesscoder / numerolog-phpunit example snippets
// Success only if $value has a standard deviation inside specified tolerance:
$this->assertWithinStandardDeviation($counterName, $value, $allowedStandardDeviation = 1, $count = 20);
// Success if $value is above current minimum and below current maximum:
$this->assertWithinSetRange($counterName, $value, $count = 20);
// Opposite of the above
$this->assertNotWithinSetRange($counterName, $value, $count = 20);
// Success only if $value exists as an exact match (also for floats!) in set:
$this->assertExactlyWithinSetRange($counterName, $value, $count = 20);
// Opposite of the above
$this->assertNotExactlyWithinSetRange($counterName, $value, $count = 20);
public function testExpectedMemoryUsageOfMyFunctionOnMyClassIsSameOrLower() {
$subject = new MyClass('myconstructorvalue');
$monitor = new Monitor($subject);
$subject->doSomethingMemoryIntensive(1000);
$usage = $monitor->getMemoryUsage();
// method always uses memory; no usage or freed memory is an early failure:
$this->assertGreaterThan(0, $usage);
// assertion: no more than 2 standard deviations allowed. Include 40 values in set:
$this->assertWithinStandardDeviation('myFunctionMemoryUsage', $usage, 2, 40);
// assertion: value should be less than or equal to average recorded usage:
$this->assertLessThanOrEqualToAverage('myFunctionMemoryUsage', $usage, 40);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.