Skip to content

Instantly share code, notes, and snippets.

View filipfilipovich's full-sized avatar

Filip Filipovic filipfilipovich

  • Croatia
View GitHub Profile
<?php
test('user authorization', function () {
$auth = Mockery::mock(Auth::class);
$auth->shouldReceive('login');
$auth->shouldReceive('authorize');
$user = new UserRepository($auth);
expect($user->getAuthorized())
->not->toBeEmpty();
<?php
test('calculation', function () {
$result = 2 * 4;
expect($result)
->toBeInt() // Assert that the result is an integer
->toBe(8) // Assert that the result value is 8
->not->toBeJson() // Using "not" modifier, asserting that the value isn't JSON
->not->toBe(5); // Another usage example of "not" modifier
<?php
beforeAll(function () {
// Executes first, before any of tests are run
// Eg. can be used to set up a testing database
});
beforeEach(function () {
$this->bookRepository = new BookRepository();
});