for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Tests\Entity;
use PHPUnit\Framework\TestCase;
use App\Entity\Book;
/**
* Test cases for class Book.
*/
class BookTest extends TestCase
{
* testCreateObject
*
* Construct object and verify that the object has the expected
* properties, use no arguments.
* @return void
public function testCreateObject(): void
$book = new Book();
$this->assertInstanceOf(Book::class, $book);
}
* testSetAndGetMethods
* Test the set and get methods
public function testSetAndGetMethods(): void
$book->setTitle("Test");
$book->setISBN("1234567891234");
$book->setAuthor("Test");
$book->setImg("Test");
$this->assertNull($book->getId());
$this->assertEquals("Test", $book->getTitle());
$this->assertEquals("1234567891234", $book->getISBN());
$this->assertEquals("Test", $book->getAuthor());
$this->assertEquals("Test", $book->getImg());
//Test the setters is null
$book->setISBN(null);
$book->setAuthor(null);
$book->setImg(null);
$this->assertNull($book->getISBN());
$book->getISBN()
App\Entity\Book::getISBN()
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.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
$this->assertNull($book->getAuthor());
$book->getAuthor()
App\Entity\Book::getAuthor()
$this->assertNull($book->getImg());
$book->getImg()
App\Entity\Book::getImg()
This check looks for function or method calls that always return null and whose return value is used.
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.