Skip to content

Commit

Permalink
Merge pull request #12 from sroehrl/release/0.3.6
Browse files Browse the repository at this point in the history
BUGFIX & testsuite
  • Loading branch information
sroehrl authored Oct 26, 2022
2 parents 3eecddd + b2188b7 commit b35975a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/report
14 changes: 7 additions & 7 deletions DbOps.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ private function prepareBinding($value, $type): array
* @param bool $set
* @param bool $prepared
*
* @return mixed
* @return string
* @throws DbException
*/
protected function operandi($input, bool $set, bool $prepared)
protected function operandi($input, bool $set, bool $prepared): string
{
switch (gettype($input)){
case 'integer':
return $input;
return ' = ' . $input;
case 'NULL':
return $this->setNull($input, $set);
return $this->setNull($set);
}
if (empty($input)) {
return $this->setNull($input, $set);
return $this->setNull($set);
}
$firstLetter = strtolower(substr($input, 0, 1));
switch ($firstLetter) {
Expand Down Expand Up @@ -139,7 +139,7 @@ protected function operandi($input, bool $set, bool $prepared)
break;
default:
if (strtolower($input) == 'null') {
$return = ($set ? ' = NULL' : ' IS NULL');
$return = $this->setNull($set);
} elseif ($prepared) {
$return = preg_match('/%/', $input) ? ' LIKE ? ' : ' = ? ';
$this->addExclusion($input);
Expand All @@ -151,7 +151,7 @@ protected function operandi($input, bool $set, bool $prepared)
return $return;
}

protected function setNull($value, bool $set): string
protected function setNull(bool $set): string
{
return ($set ? ' = NULL' : ' IS NULL');
}
Expand Down
36 changes: 36 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
stderr="true"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./</directory>
</include>
<exclude>
<directory>./test</directory>
<directory>./vendor</directory>
<directory>./.github</directory>
<directory suffix="Test.php">./</directory>
</exclude>
<report>
<clover outputFile="test/clover.xml"/>
<html outputDirectory="test/report"/>
</report>
</coverage>
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">./test</directory>
</testsuite>
</testsuites>
<php>
<const name="base" value="http://localhost"/>
</php>
<logging/>
</phpunit>

0 comments on commit b35975a

Please sign in to comment.