Codeception / Codeception/module-db

Support for IN operator in Db Module

Open
#17 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
23
Forks
31
PR merge metrics
No merged PRs in 30d

Description

#### What are you trying to achieve?
I wanted to check that `$I->dontSeeInDatabase` from a list of values. Instead of writing
```php
$I->dontSeeInDatabase('someTable', ['foo' => 'cond1']);
$I->dontSeeInDatabase('someTable', ['foo' => 'cond2']);
$I->dontSeeInDatabase('someTable', ['foo' => 'cond3']);
```
I ended up writing
```php
$I->dontSeeInDatabase('someTable', [
'foo' => ['cond1', 'cond2', 'cond3']
]);
```
hoping that it would generate the following query `SELECT count(*) FROM someTable WHERE foo IN ('cond1', 'cond2', 'cond3')` and assert that the result must be 0. However I ended up getting an exception, saying array-to-string conversion - obviously enough since this is not supported.

Do you think this is something good to have, or just bad test design on my part?

* Codeception version: 2.3.3

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the $I->dontSeeInDatabase entry point in the Db module and trace how array conditions are converted into a query. Reproduce the reported array-of-values case, then add support for the requested IN behavior and verify that the resulting assertion treats matching rows as absent.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
database, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.