diff --git a/README.md b/README.md index d256d3d..9bd259f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # api-template A template project for php-api + +[![GitHub License](https://img.shields.io/github/license/kilip/api-template?style=flat-square) +](https://github.com/kilip/api-template?tab=MIT-1-ov-file) +[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/kilip/api-template/ci.yaml?branch=main&style=flat-square) +](https://github.com/kilip/api-template/actions/workflows/ci.yaml) +[![Codecov](https://img.shields.io/codecov/c/github/kilip/api-template?style=flat-square)](https://app.codecov.io/gh/kilip/api-template) diff --git a/src/Entity/Books.php b/src/Entity/Books.php index 3f45cf9..4ceb76a 100644 --- a/src/Entity/Books.php +++ b/src/Entity/Books.php @@ -24,8 +24,28 @@ class Books public int $id; #[ORM\Column(type: 'string')] - public string $title; + private string $title; #[ORM\Column(type: 'string')] - public string $author; + private string $author; + + public function setTitle(string $title): void + { + $this->title = $title; + } + + public function getTitle(): string + { + return $this->title; + } + + public function setAuthor(string $author): void + { + $this->author = $author; + } + + public function getAuthor(): string + { + return $this->author; + } } diff --git a/tests/Functional/BooksTest.php b/tests/Functional/BooksTest.php index 60ad6ac..7ba7adc 100644 --- a/tests/Functional/BooksTest.php +++ b/tests/Functional/BooksTest.php @@ -41,14 +41,16 @@ public function testCrud(): void $this->ensureBookNotExists('test'); $book = new Books(); - $book->author = 'Test'; - $book->title = 'Test Book'; - $filter = ['title' => $book->title]; + $book->setAuthor('Test'); + $book->setTitle('Test Book'); + $filter = ['title' => $book->getTitle()]; $manager->persist($book); $manager->flush(); $this->assertInstanceOf(Books::class, $repository->findOneBy($filter)); $this->assertNotNull($book->id); + $this->assertSame('Test', $book->getAuthor()); + $this->assertSame('Test Book', $book->getTitle()); } private function ensureBookNotExists(string $title): void