Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomano committed Nov 12, 2024
1 parent 40a7fb9 commit dfa9f94
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
4 changes: 3 additions & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
Utils::$smcFunc['htmlspecialchars'] = fn(...$params) => htmlspecialchars(...$params);

Utils::$smcFunc['db_query'] = fn(...$params) => new \stdClass();
Utils::$smcFunc['db_search_query'] = Utils::$smcFunc['db_query'];
Utils::$smcFunc['db_fetch_row'] = fn(...$params) => [];
Utils::$smcFunc['db_fetch_assoc'] = fn(...$params) => [];
Utils::$smcFunc['db_fetch_all'] = fn(...$params) => [];
Utils::$smcFunc['db_free_result'] = fn(...$params) => true;
Utils::$smcFunc['db_insert'] = fn(...$params) => 0;
Utils::$smcFunc['db_num_rows'] = fn(...$params) => 0;
Utils::$smcFunc['db_transaction'] = fn(...$params) => true;
Utils::$smcFunc['db_optimize_table'] = fn(...$params) => 0;
Utils::$smcFunc['db_list_tables'] = fn(...$params) => [];
Utils::$smcFunc['db_get_version'] = fn(...$params) => '';
Utils::$smcFunc['db_create_table'] = fn(...$params) => false;
})->in(__DIR__);

/*
Expand Down
25 changes: 20 additions & 5 deletions tests/Unit/DbFuncMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
->toEqual(Utils::$smcFunc['db_query'](...$this->params));
});

test('search_query method', function () {
expect($this->db->search_query(...$this->params))
->toEqual(Utils::$smcFunc['db_search_query'](...$this->params));
});

test('fetch_row method', function () {
expect($this->db->fetch_row($this->resourse))
->toBeArray();
Expand All @@ -45,7 +40,27 @@
->toBeTrue();
});

test('optimize_table method', function () {
expect($this->db->optimize_table(''))
->toBeInt();
});

test('list_tables method', function () {
expect($this->db->list_tables())
->toBeArray();
});

test('get_version method', function () {
expect($this->db->get_version())
->toBeString();
});

test('create_table method', function () {
expect($this->db->create_table('', []))
->toBeFalse();
});

test('__call method', function () {
expect($this->db->unknown($this->params))
->toBeFalse();
});

0 comments on commit dfa9f94

Please sign in to comment.