mirror of
https://github.com/pnx/neotest-phpunit
synced 2026-06-18 04:10:01 +02:00
Add example tests
This commit is contained in:
parent
f6c7185eb7
commit
a38eaeeaef
2 changed files with 32 additions and 0 deletions
32
tests/Feature/UserTest.php
Normal file
32
tests/Feature/UserTest.php
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use TestProject\User;
|
||||||
|
|
||||||
|
$makeUser = fn () => 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);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue