-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: renamed entity class, added missing tests
- Loading branch information
Showing
7 changed files
with
87 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace phpMyFAQ; | ||
|
||
use phpMyFAQ\Database\Sqlite3; | ||
use phpMyFAQ\Entity\Tag; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class TagsTest extends TestCase | ||
{ | ||
private Tags $tags; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$dbHandle = new Sqlite3(); | ||
$dbHandle->connect(PMF_TEST_DIR . '/test.db', '', ''); | ||
$configuration = new Configuration($dbHandle); | ||
|
||
$this->tags = new Tags($configuration); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
$this->tags->deleteByRecordId(1); | ||
} | ||
|
||
public function testCreate(): void | ||
{ | ||
$testData = ['Foo', 'Bar', 'Baz']; | ||
$result = $this->tags->create(1, $testData); | ||
|
||
$this->assertTrue($result); | ||
} | ||
|
||
public function testDeleteByRecordId(): void | ||
{ | ||
$testData = ['Foo', 'Bar', 'Baz']; | ||
$this->tags->create(1, $testData); | ||
|
||
$this->assertTrue($this->tags->deleteByRecordId(1)); | ||
} | ||
|
||
public function testUpdate(): void | ||
{ | ||
$testData = ['Foo', 'Bar', 'Baz']; | ||
$this->tags->create(1, $testData); | ||
|
||
$tag = new Tag(); | ||
$tag->setId(1); | ||
$tag->setName('Foooooooo'); | ||
|
||
$this->assertTrue($this->tags->update($tag)); | ||
$this->assertEquals('Foooooooo', $this->tags->getTagNameById(1)); | ||
} | ||
|
||
public function testDelete(): void | ||
{ | ||
$testData = ['Foo', 'Bar', 'Baz']; | ||
$this->tags->create(1, $testData); | ||
|
||
$this->assertTrue($this->tags->delete(1)); | ||
$this->assertEmpty($this->tags->getTagNameById(1)); | ||
} | ||
} |