1
0
Fork 0
mirror of https://github.com/pnx/neotest-phpunit synced 2026-06-16 03:54:55 +02:00

Add example tests

This commit is contained in:
Michael Utz 2022-11-14 22:43:05 +03:00
parent f6c7185eb7
commit a38eaeeaef
2 changed files with 32 additions and 0 deletions

View 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);