From bb8d42f21facff3440749e814878678ed3065133 Mon Sep 17 00:00:00 2001 From: masterWeber Date: Thu, 7 Jan 2021 13:06:49 +0300 Subject: [PATCH] Increased test coverage --- src/Clause/Condition.php | 4 ++-- src/Clause/OrderBy.php | 4 ---- src/Expression/Expression.php | 4 ---- src/Operator/Operator.php | 4 ---- tests/Clause/OrderByTest.php | 2 +- tests/SqlBuilderTest.php | 1 - 6 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Clause/Condition.php b/src/Clause/Condition.php index 0e03a14..cd43568 100644 --- a/src/Clause/Condition.php +++ b/src/Clause/Condition.php @@ -27,7 +27,7 @@ use SQLBuilder\Operator\Operator; use SQLBuilder\Stringable_; -class Condition implements Stringable_ +class Condition extends Expression implements Stringable_ { protected ?Stringable_ $parent; protected array $expressions; @@ -215,7 +215,7 @@ protected function buildExpressions(): string } if ($expression instanceof Expression) { - $str .= $expression->__toString(); + $str .= $expression; } elseif (is_string($expression)) { $str .= $expression; } else { diff --git a/src/Clause/OrderBy.php b/src/Clause/OrderBy.php index 86d724e..25e411a 100644 --- a/src/Clause/OrderBy.php +++ b/src/Clause/OrderBy.php @@ -46,10 +46,6 @@ public function __construct($expression, $sorting = self::ASC, Stringable_ $pare public function __toString(): string { - if (empty($this->expressionList)) { - return ''; - } - $str = ''; foreach ($this->expressionList as $orderBy) { $str .= ', ' . Helper::quoteColumn($orderBy[0]); diff --git a/src/Expression/Expression.php b/src/Expression/Expression.php index f3159ab..c64ff1d 100644 --- a/src/Expression/Expression.php +++ b/src/Expression/Expression.php @@ -8,8 +8,4 @@ abstract class Expression implements Stringable_ { - public function __toString(): string - { - return ''; - } } \ No newline at end of file diff --git a/src/Operator/Operator.php b/src/Operator/Operator.php index e11d10f..e9da32b 100644 --- a/src/Operator/Operator.php +++ b/src/Operator/Operator.php @@ -8,8 +8,4 @@ abstract class Operator implements Stringable_ { - public function __toString(): string - { - return ''; - } } \ No newline at end of file diff --git a/tests/Clause/OrderByTest.php b/tests/Clause/OrderByTest.php index 351ad54..528d609 100644 --- a/tests/Clause/OrderByTest.php +++ b/tests/Clause/OrderByTest.php @@ -18,7 +18,7 @@ public function testToString() $orderBy = new OrderBy([ 'col_name' => OrderBy::DESC, - 'col_name_1' => OrderBy::ASC, + 'col_name_1', ]); $this->assertEquals( diff --git a/tests/SqlBuilderTest.php b/tests/SqlBuilderTest.php index 96abcbb..f6686a1 100644 --- a/tests/SqlBuilderTest.php +++ b/tests/SqlBuilderTest.php @@ -91,7 +91,6 @@ public function testDelete(): void ->from('table_name') ->where() ->equal('col1', 2) - ->and() ->equal('col2', 23) ->limit(3);