Merge pull request #57 from michaelachrisco/56-add-context-to-kahlan

feat(spec): Testing users should have more context
This commit is contained in:
Michael Chrisco 2024-01-17 12:15:36 -08:00 committed by GitHub
commit 276836059b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 179 additions and 164 deletions

View file

@ -19,9 +19,19 @@ jobs:
- run: sudo composer self-update - run: sudo composer self-update
- run: composer install -n --prefer-dist --no-plugins - run: composer install -n --prefer-dist --no-plugins
- run: ./vendor/bin/kahlan -reporter=verbose - run: ./vendor/bin/kahlan -reporter=verbose
build_php_version_83:
docker:
- image: cimg/php:8.3.0
working_directory: ~/ReadOnlyTraitLaravel
steps: # a set of executable commands
- checkout
- run: sudo composer self-update
- run: composer install -n --prefer-dist --no-plugins
- run: ./vendor/bin/kahlan -reporter=verbose
workflows: workflows:
version: 2 version: 2
build: build:
jobs: jobs:
- build_php_version_81 - build_php_version_81
- build_php_version_82 - build_php_version_82
- build_php_version_83

View file

@ -4,11 +4,13 @@ require_once('src/ReadOnlyTrait.php');
use MichaelAChrisco\ReadOnly\ReadOnlyException; use MichaelAChrisco\ReadOnly\ReadOnlyException;
use MichaelAChrisco\ReadOnly\ReadOnlyTrait; use MichaelAChrisco\ReadOnly\ReadOnlyTrait;
class User extends Illuminate\Database\Eloquent\Model { class User extends Illuminate\Database\Eloquent\Model
{
use ReadOnlyTrait; use ReadOnlyTrait;
} }
describe("User", function () { describe("User", function () {
context("When User calls unsupported method", function () {
describe("::create()", function () { describe("::create()", function () {
it("is expected to throw ReadOnlyException", function () { it("is expected to throw ReadOnlyException", function () {
expect( expect(
@ -163,6 +165,7 @@ describe("User", function() {
}); });
}); });
}); });
});
class MockModel class MockModel
{ {
@ -183,6 +186,7 @@ class UserReadOnlyNotActive extends MockModel
} }
describe("UserReadOnlyNotActive", function () { describe("UserReadOnlyNotActive", function () {
context("When UserReadOnlyNotActive calls unsupported method and isActive is true", function () {
describe("::create()", function () { describe("::create()", function () {
it("expects `create()` to be toBeTruthy", function () { it("expects `create()` to be toBeTruthy", function () {
$user = new UserReadOnlyNotActive; $user = new UserReadOnlyNotActive;
@ -190,3 +194,4 @@ describe("UserReadOnlyNotActive", function () {
}); });
}); });
}); });
});