Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kilip committed Aug 18, 2024
1 parent d026aeb commit e8c802b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 22 additions & 2 deletions src/Entity/Books.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
8 changes: 5 additions & 3 deletions tests/Functional/BooksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8c802b

Please sign in to comment.