1. Go to this page and download the library: Download codeception/domain-assert 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/ */
codeception / domain-assert example snippets
$this->assertTrue($user->isValid(), 'user is valid');
$this->assertUserIsValid($user);
use Codeception\DomainRule;
trait CustomAssertion
{
public function assertValidUser(User $user)
{
$this->assertThat(
['user' => $user],
new DomainRule('user and user.isValid()')
);
}
}
class UserTest extends \PHPUnit\Framework\TestCase
{
use CustomAssertion;
}
public function assertEnoughProductsInStock(Stock stock, Product product, amount)
{
$this->assertThat([
'product' => $product,
'stock' => $stock,
'amount' => $amount
],
new DomainRule('stock and product.getStock() == stock and product.getAmount() > amount')
);
}
$product = new Product('iPhone');
$stock->addProduct($product);
$stock->addProduct($product);
$stock->addProduct($product);
$this->assertEnoughProductsInStock($stock, $product, 2);
public function assertIsGreaterThanMinimal()
{
$this->assertThat(
$minimalPrice,
new DomainRule('expected > 1000')
);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.