Passed
Push — main ( f3cfb1...17781b )
by Emil
04:34
created

BookTest::testSetAndGetMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 21
rs 9.7333
c 1
b 1
f 0
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
        $book->setTitle("Test");
38
        $book->setISBN("1234567891234");
39
        $book->setAuthor("Test");
40
        $book->setImg("Test");
41
42
        $this->assertNull($book->getId());
43
        $this->assertEquals("Test", $book->getTitle());
44
        $this->assertEquals("1234567891234", $book->getISBN());
45
        $this->assertEquals("Test", $book->getAuthor());
46
        $this->assertEquals("Test", $book->getImg());
47
48
        //Test the setters is null
49
        $book->setISBN(null);
50
        $book->setAuthor(null);
51
        $book->setImg(null);
52
        $this->assertNull($book->getISBN());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $book->getISBN() targeting App\Entity\Book::getISBN() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
53
        $this->assertNull($book->getAuthor());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $book->getAuthor() targeting App\Entity\Book::getAuthor() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
54
        $this->assertNull($book->getImg());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $book->getImg() targeting App\Entity\Book::getImg() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
55
    }
56
}
57