From a38eaeeaef1b5ea6c85d065334e590c3210f2455 Mon Sep 17 00:00:00 2001 From: Michael Utz Date: Mon, 14 Nov 2022 22:43:05 +0300 Subject: [PATCH] Add example tests --- tests/Feature/UserTest.php | 32 ++++++++++++++++++++++++++++++++ tests/{ => Unit}/ExampleTest.php | 0 2 files changed, 32 insertions(+) create mode 100644 tests/Feature/UserTest.php rename tests/{ => Unit}/ExampleTest.php (100%) diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php new file mode 100644 index 0000000..b19fea9 --- /dev/null +++ b/tests/Feature/UserTest.php @@ -0,0 +1,32 @@ + new User(18, 'John'); + +test('class constructor') + ->expect($makeUser) + ->name->toBe('John') + ->age->toBe(18) + ->favorite_movies->toBeEmpty(); + +test('tellName') + ->expect($makeUser) + ->tellName()->toBeString()->toContain('John'); + +test('tellAge') + ->expect($makeUser) + ->tellAge()->toBeString()->toContain('18'); + +test('addFavoriteMovie') + ->expect($makeUser) + ->addFavoriteMovie('Avengers') + ->toBeTrue() + ->favorite_movies->toContain('Avengers')->toHaveLength(1); + +test('removeFavoriteMovie') + ->expect($makeUser) + ->addFavoriteMovie('Avengers')->toBeTrue() + ->addFavoriteMovie('Justice League')->toBeTrue() + ->removeFavoriteMovie('Avengers')->toBeTrue() + ->favorite_movies->not->toContain('Avengers')->toHaveLength(1); diff --git a/tests/ExampleTest.php b/tests/Unit/ExampleTest.php similarity index 100% rename from tests/ExampleTest.php rename to tests/Unit/ExampleTest.php