Skip to content

Commit

Permalink
fix: added missing cleanup of tables
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Mar 30, 2024
1 parent c7d0bbe commit 5834577
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/phpMyFAQ/RelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,50 @@
namespace phpMyFAQ;

use phpMyFAQ\Configuration\DatabaseConfiguration;
use PHPUnit\Framework\MockObject\Exception;
use phpMyFAQ\Database\Sqlite3;
use PHPUnit\Framework\TestCase;
use stdClass;

class RelationTest extends TestCase
{
private Sqlite3 $db;

protected function tearDown(): void
{
parent::tearDown();

$this->db->query('DELETE FROM faqdata WHERE id = 1');
$this->db->query('DELETE FROM faqcategoryrelations WHERE category_id = 1');
}

/**
* @throws \Exception
*/
public function testGetAllRelatedByQuestion(): void
{
$dbConfig = new DatabaseConfiguration(PMF_TEST_DIR . '/content/core/config/database.php');
Database::setTablePrefix($dbConfig->getPrefix());
$db = Database::factory($dbConfig->getType());
$db->connect(
$this->db = Database::factory($dbConfig->getType());
$this->db->connect(
$dbConfig->getServer(),
$dbConfig->getUser(),
$dbConfig->getPassword(),
$dbConfig->getDatabase(),
$dbConfig->getPort()
);
$configuration = new Configuration($db);
$configuration = new Configuration($this->db);
$configuration->set('search.enableRelevance', false);

$language = new Language($configuration);
$language->setLanguage(false, 'en');
$configuration->setLanguage($language);

$db->query(
$this->db->query(
'INSERT INTO faqdata ' .
'(id, lang, solution_id, sticky, thema, content, keywords, active, author, email, updated) VALUES ' .
'(1, \'en\', 1000, \'yes\', \'sample question\', \'sample answer\', \'sample keywords\', \'yes\', \'Author\', \'test@example.org\', \'date\')'
);
$db->query(
$this->db->query(
'INSERT INTO faqcategoryrelations (category_id, category_lang, record_id, record_lang) VALUES (1, \'en\', 1, \'en\')'
);

Expand Down
1 change: 1 addition & 0 deletions tests/phpMyFAQ/SitemapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class SitemapTest extends TestCase
private Sitemap $sitemap;

private Sqlite3 $db;

protected function setUp(): void
{
parent::setUp();
Expand Down

0 comments on commit 5834577

Please sign in to comment.