PHP code example of beyondit / opencart-test-suite
1. Go to this page and download the library: Download beyondit/opencart-test-suite 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/ */
beyondit / opencart-test-suite example snippets
namespace Tests;
class ModelCatalogManufacturerTest extends OpenCartTest
{
public function testASpecificManufacturer()
{
// load the manufacturer model
$model = $this->loadModel("catalog/manufacturer");
$manufacturer = $model->getManufacturer(5);
// test a specific assertion
$this->assertEquals('HTC', $manufacturer['name']);
}
}
namespace Tests;
class ControllerCheckoutCartTest extends OpenCartTest
{
public function testAddingASpecificProductToTheCart()
{
$response = $this->dispatchAction('checkout/cart/add','POST',['product_id' => 28]);
$output = json_decode($response->getOutput(),true);
$this->assertTrue(isset($output['success']) && isset($output['total']));
$this->assertRegExp('/HTC Touch HD/', $output['success']);
}
}
class ControllerAccountEditTest extends OpenCartTest {
public function testEditAccountWithLoggedInCustomer() {
$this->login('[email protected]','password');
$response = $this->dispatchAction('account/edit');
$this->assertRegExp('/Your Personal Details/',$response->getOutput());
$this->logout();
}
}
class ControllerCommonDashboardAdminTest extends OpenCartTest {
public function testShowDashboardWithLoggedInUser() {
$this->login('admin','admin');
$response = $this->dispatchAction('common/dashboard');
$this->assertRegExp('/Total Sales/', $response->getOutput());
$this->logout();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.