1. Go to this page and download the library: Download codeception/verify 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 / verify example snippets
use Codeception\Verify\Verify;
$user = User::find(1);
// equals
verify($user->getName())->equals('davert');
verify($user->getNumPosts())
->equals(5, 'user have 5 posts')
->notEquals(3);
// contains
Verify::Array($user->getRoles())
->contains('admin', 'first user is admin')
->notContains('banned', 'first user is not banned');
// greater / less
verify($user->getRate())
->greaterThan(5)
->lessThan(10)
->equals(7, 'first user rate is 7');
// true / false / null
verify($user->isAdmin())->true();
verify($user->isBanned())->false();
verify($user->invitedBy)->null();
verify($user->getPosts())->notNull();
// empty
verify($user->getComments())->empty();
verify($user->getRoles())->notEmpty();
// throws
Verify::Callable($callback)
->throws()
->throws(Exception::class)
->throws(Exception::class, 'exception message')
->throws(new Exception())
->throws(new Exception('message'));
// does not throw
Verify::Callable($callback)
->doesNotThrow()
->throws(Exception::class)
->doesNotThrow(new Exception());
// and many more !
expect($user->getNumPosts())
->notToBeNull()
->toBeInt()
->toEqual(5, 'user have 5 posts');
verify_that($user->getRate())->equals(7, 'first user rate is 7');
use Codeception\Verify\Verify;
use PHPUnit\Framework\Assert;
class MyVerify extends Verify {
//you can type $actual to only receive a specific data type
public function __construct($actual = null)
{
parent::__construct($actual);
}
public function success(string $message = '')
{
Assert::assertTrue(true, $message);
}
}
$myVerify = new MyVerify;
$myVerify->success('it works!');
$myVerify::Mixed('this also')->notEquals('works');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.