1. Go to this page and download the library: Download data-provider/example 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/ */
data-provider / example example snippets
/**
* Data provider for testCalculateTotal
* variables are in the order of
* $paymentMethod, $expectedTotal
*
* @return type
*/
public function paymentMethodProvider()
{
return [
['Cash', 100.00],
['Credit Card', 95.00],
];
}
/**
* Test to check if the order total is calculated correctly
* for given payment method.
*
* @param string $paymentMethod
* @param float $expectedTotal
*
* @dataProvider paymentMethodProvider
*/
public function testCalculateTotal($paymentMethod, $expectedTotal)
{
$this->checkout->calculateTotal($paymentMethod);
$this->assertEquals(
$this->checkout->getTotal(),
$expectedTotal,
sprintf('Testing total calculation for %s.', $paymentMethod)
);
}
phpunit --bootstrap=vendor/autoload.php tests
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.