Skip to content

Commit 600c40c

Browse files
committed
Improve quality tools + unit test
1 parent 9ef43e0 commit 600c40c

File tree

5 files changed

+75
-6
lines changed

5 files changed

+75
-6
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ Makefile text
2525
/Makefile export-ignore
2626
/phpmd.xml export-ignore
2727
/phpstan.neon export-ignore
28+
/phpunit.xml export-ignore
2829
/psalm.xml export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
/.php_cs.cache
66
/.phpunit.cache/
7+
/.phpunit.result.cache

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"sgh/comparable": "^1.1"
2222
},
2323
"require-dev": {
24+
"enlightn/security-checker": "^1.5",
2425
"ergebnis/composer-normalize": "^2.13",
2526
"friendsofphp/php-cs-fixer": "^2.16",
2627
"insolita/unused-scanner": "^2.2",
@@ -31,7 +32,6 @@
3132
"phpunit/phpunit": "^9.5",
3233
"rskuipers/php-assumptions": "^0.8.0",
3334
"sebastian/phpcpd": "^6.0",
34-
"sensiolabs/security-checker": "^6.0",
3535
"vimeo/psalm": "^4.2"
3636
},
3737
"autoload": {

phpunit.xml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheResultFile=".phpunit.cache/test-results"
6+
executionOrder="depends,defects"
7+
forceCoversAnnotation="true"
8+
beStrictAboutCoversAnnotation="true"
9+
beStrictAboutOutputDuringTests="true"
10+
beStrictAboutTodoAnnotatedTests="true"
11+
stopOnFailure="true"
12+
stopOnError="true"
13+
stopOnDefect="true"
14+
failOnEmptyTestSuite="true"
15+
stopOnWarning="true"
16+
beStrictAboutTestsThatDoNotTestAnything="true"
17+
beStrictAboutResourceUsageDuringSmallTests="true"
18+
beStrictAboutChangesToGlobalState="true"
19+
cacheResult="true"
20+
convertDeprecationsToExceptions="true"
21+
convertErrorsToExceptions="true"
22+
convertNoticesToExceptions="true"
23+
convertWarningsToExceptions="true"
24+
failOnIncomplete="false"
25+
failOnSkipped="false"
26+
stopOnIncomplete="false"
27+
stopOnRisky="false"
28+
stopOnSkipped="false"
29+
failOnRisky="true"
30+
failOnWarning="true"
31+
verbose="true">
32+
<testsuites>
33+
<testsuite name="default">
34+
<directory suffix="Test.php">tests</directory>
35+
</testsuite>
36+
</testsuites>
37+
38+
<coverage cacheDirectory=".phpunit.cache/code-coverage"
39+
processUncoveredFiles="true">
40+
<include>
41+
<directory suffix=".php">src</directory>
42+
</include>
43+
</coverage>
44+
</phpunit>

tests/Search/QueryBuilder/NumericFacetTest.php

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
11
<?php
22

3+
declare(strict_types=1);
4+
5+
/*
6+
* Copyright MacFJA
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
9+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
10+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
11+
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
14+
* Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17+
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
322
namespace Tests\MacFJA\RediSearch\Search\QueryBuilder;
423

524
use MacFJA\RediSearch\Search\QueryBuilder\NumericFacet;
625
use PHPUnit\Framework\TestCase;
726

827
/**
928
* @coversDefaultClass \MacFJA\RediSearch\Search\QueryBuilder\NumericFacet
29+
* @covers ::render
30+
*
31+
* @uses \MacFJA\RediSearch\Helper\EscapeHelper
32+
* @uses \MacFJA\RediSearch\Search\QueryBuilder\NumericFacet
1033
*
1134
* @see: https://oss.redislabs.com/redisearch/Query_Syntax/#mapping_common_sql_predicates_to_redisearch
1235
* WHERE num BETWEEN 10 AND 20 @num:[10 20]
@@ -24,7 +47,7 @@ class NumericFacetTest extends TestCase
2447
public function testGreaterThan()
2548
{
2649
$facet = NumericFacet::greaterThan('num', 10);
27-
$this->assertSame('@num:[(10 +inf]', $facet->render());
50+
self::assertSame('@num:[(10 +inf]', $facet->render());
2851
}
2952

3053
/**
@@ -33,7 +56,7 @@ public function testGreaterThan()
3356
public function testGreaterThanOrEquals()
3457
{
3558
$facet = NumericFacet::greaterThanOrEquals('num', 10);
36-
$this->assertSame('@num:[10 +inf]', $facet->render());
59+
self::assertSame('@num:[10 +inf]', $facet->render());
3760
}
3861

3962
/**
@@ -42,7 +65,7 @@ public function testGreaterThanOrEquals()
4265
public function testLessThan()
4366
{
4467
$facet = NumericFacet::lessThan('num', 10);
45-
$this->assertSame('@num:[-inf (10]', $facet->render());
68+
self::assertSame('@num:[-inf (10]', $facet->render());
4669
}
4770

4871
/**
@@ -51,7 +74,7 @@ public function testLessThan()
5174
public function testLessThanOrEquals()
5275
{
5376
$facet = NumericFacet::lessThanOrEquals('num', 10);
54-
$this->assertSame('@num:[-inf 10]', $facet->render());
77+
self::assertSame('@num:[-inf 10]', $facet->render());
5578
}
5679

5780
/**
@@ -60,6 +83,6 @@ public function testLessThanOrEquals()
6083
public function testEqualsTo()
6184
{
6285
$facet = NumericFacet::equalsTo('num', 10);
63-
$this->assertSame('@num:[10 10]', $facet->render());
86+
self::assertSame('@num:[10 10]', $facet->render());
6487
}
6588
}

0 commit comments

Comments
 (0)