|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Tests\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
6
|
|
|
use App\Entity\Book; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Test cases for class Book. |
|
10
|
|
|
*/ |
|
11
|
|
|
class BookTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* testCreateObject |
|
15
|
|
|
* |
|
16
|
|
|
* Construct object and verify that the object has the expected |
|
17
|
|
|
* properties, use no arguments. |
|
18
|
|
|
* |
|
19
|
|
|
* @return void |
|
20
|
|
|
*/ |
|
21
|
|
|
public function testCreateObject(): void |
|
22
|
|
|
{ |
|
23
|
|
|
$book = new Book(); |
|
24
|
|
|
$this->assertInstanceOf(Book::class, $book); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* testSetAndGetMethods |
|
29
|
|
|
* |
|
30
|
|
|
* Test the set and get methods |
|
31
|
|
|
* |
|
32
|
|
|
* @return void |
|
33
|
|
|
*/ |
|
34
|
|
|
public function testSetAndGetMethods(): void |
|
35
|
|
|
{ |
|
36
|
|
|
$book = new Book(); |
|
37
|
|
|
|
|
38
|
|
|
$book->setTitle("Test"); |
|
39
|
|
|
$book->setISBN("1234567891234"); |
|
40
|
|
|
$book->setAuthor("Test"); |
|
41
|
|
|
$book->setImg("Test"); |
|
42
|
|
|
|
|
43
|
|
|
$this->assertNull($book->getId()); |
|
44
|
|
|
$this->assertEquals("Test", $book->getTitle()); |
|
45
|
|
|
$this->assertEquals("1234567891234", $book->getISBN()); |
|
46
|
|
|
$this->assertEquals("Test", $book->getAuthor()); |
|
47
|
|
|
$this->assertEquals("Test", $book->getImg()); |
|
48
|
|
|
|
|
49
|
|
|
//Test the setters is null |
|
50
|
|
|
$book->setISBN(null); |
|
51
|
|
|
$book->setAuthor(null); |
|
52
|
|
|
$book->setImg(null); |
|
53
|
|
|
|
|
54
|
|
|
/** @var string|null $isbn */ |
|
55
|
|
|
$isbn = $book->getISBN(); |
|
56
|
|
|
/** @var string|null $author */ |
|
57
|
|
|
$author = $book->getAuthor(); |
|
58
|
|
|
/** @var string|null $img */ |
|
59
|
|
|
$img = $book->getImg(); |
|
60
|
|
|
|
|
61
|
|
|
// @scrutinizer ignore-start |
|
62
|
|
|
$this->assertNull($isbn); |
|
63
|
|
|
$this->assertNull($author); |
|
64
|
|
|
$this->assertNull($img); |
|
65
|
|
|
// @scrutinizer ignore-end |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|