Skip to content

Commit ad8e3fb

Browse files
committed
Correção teste unitario.
1 parent ad785c0 commit ad8e3fb

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"illuminate/database": "^6.15"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": "^5.7",
17-
"mockery/mockery": "dev-master"
16+
"phpunit/phpunit": "^7.5.20",
17+
"mockery/mockery": "^1.3.3"
1818
},
1919
"scripts": {
2020
"test": "vendor/bin/phpunit --verbose --coverage-text"

src/NQuery.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,15 @@ private function setSubWhere($callback,$isOr = false){
494494

495495
$this->wheres .= "($subCondition)";
496496
}
497+
497498
private function checkInitialWhere(){
498499
return (strlen($this->wheres) == 0);
499500
}
500501

501502
private function checkInitialHaving(){
502503
return (strlen($this->havingValue) == 0);
503504
}
505+
504506
private function convertArrayToIn(array $value){
505507
if(is_int($value[0])){
506508
$value = implode(",",$value);
@@ -513,16 +515,7 @@ private function convertArrayToIn(array $value){
513515
}
514516
return $value;
515517
}
516-
517-
private function antiInjection($obj) {
518-
$obj = preg_replace("/(from|alter table|select|insert|delete|update|where|drop table|show tables|#|--|\\)/i", "", $obj);
519-
$obj = trim($obj);
520-
$obj = strip_tags($obj);
521-
if(!get_magic_quotes_gpc()) {
522-
$obj = addslashes($obj);
523-
return $obj;
524-
}
525-
}
518+
526519
function sqlEscapeMimic($inp) {
527520
if(is_array($inp))
528521
return array_map(__METHOD__, $inp);

src/tests/Unit/NQueryTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ public function testWhereRaw()
149149
$this->assertEquals('select coluna from tab_usuario b where b.coluna = 1 AND b.coluna = 2 or b.coluna = 3',$query->toSql());
150150
}
151151

152+
public function testWhereRawOr()
153+
{
154+
$query = new NQuery('select coluna from tab_usuario b');
155+
$query->where('b.coluna',1);
156+
$query->whereRaw('b.coluna = 2 OR b.coluna = 3',NQuery::OR);
157+
158+
159+
$this->assertEquals('select coluna from tab_usuario b where b.coluna = 1 OR b.coluna = 2 OR b.coluna = 3',$query->toSql());
160+
}
161+
152162
public function testWhereBetween()
153163
{
154164
$query = new NQuery('select coluna from tab_usuario b');

0 commit comments

Comments
 (0)