Skip to content

Commit 3353573

Browse files
authored
Merge pull request #65 from regnerisch/master
Adding tests for typesense-php
2 parents be1db86 + 6c8d735 commit 3353573

39 files changed

Lines changed: 267 additions & 36 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.idea
22
.tmp
3+
.phpunit.result.cache
34
/composer.lock
5+
phpunit.xml
46
vendor

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ Run Typesense Server:
4949
composer run-script typesenseServer
5050
```
5151

52+
Run tests:
53+
54+
```shell script
55+
docker compose up
56+
cp phpunit.xml.dist phpunit.xml
57+
composer run-script test
58+
```
59+
5260
## Credits
5361

5462
This client was originally developed by [Abdullah Al-Faqeir](https://github.org/abdullahfaqeir) from

composer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
"Typesense\\": "src/"
3030
}
3131
},
32+
"autoload-dev": {
33+
"psr-4": {
34+
"Tests\\": "tests/"
35+
}
36+
},
3237
"require": {
3338
"php": ">=7.4",
3439
"ext-json": "*",
@@ -42,6 +47,7 @@
4247
"psr/http-factory": "^1.0"
4348
},
4449
"require-dev": {
50+
"phpunit/phpunit": "^11.2",
4551
"squizlabs/php_codesniffer": "3.*",
4652
"symfony/http-client": "^5.2"
4753
},
@@ -57,6 +63,7 @@
5763
"Composer\\Config::disableProcessTimeout",
5864
"docker-compose up"
5965
],
66+
"test": "vendor/bin/phpunit",
6067
"lint": "phpcs -v",
6168
"lint:fix": "phpcbf"
6269
}

examples/collection_operations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
echo "--------Delete Document-------\n";
195195
echo "\n";
196196
echo "--------Import Documents-------\n";
197-
$docsToImport = [];
197+
$docsToImport = [];
198198
$exportedDocStrsArray = explode('\n', $exportedDocStrs);
199199
foreach ($exportedDocStrsArray as $exportedDocStr) {
200200
$docsToImport[] = json_decode($exportedDocStr, true);

phpcs.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
<file>src</file>
77
<file>examples</file>
8+
<file>tests/</file>
89

910
<exclude-pattern>*/src/Standards/*/Tests/*\.(inc|css|js)$</exclude-pattern>
1011
<exclude-pattern>*/tests/Core/*/*\.(inc|css|js)$</exclude-pattern>
@@ -42,4 +43,4 @@
4243
</property>
4344
</properties>
4445
</rule>
45-
</ruleset>
46+
</ruleset>

phpunit.xml.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5+
>
6+
<testsuites>
7+
<testsuite name="feature">
8+
<directory>tests/Feature</directory>
9+
</testsuite>
10+
</testsuites>
11+
12+
<php>
13+
<env name="TYPESENSE_NODE_HOST" value="host.docker.internal" />
14+
<env name="TYPESENSE_NODE_PORT" value="8108" />
15+
<env name="TYPESENSE_NODE_PROTOCOL" value="http" />
16+
<env name="TYPESENSE_API_KEY" value="xyz" />
17+
</php>
18+
</phpunit>

src/Alias.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
class Alias
1616
{
17-
1817
/**
1918
* @var string
2019
*/

src/Aliases.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
class Aliases implements \ArrayAccess
1616
{
17-
1817
public const RESOURCE_PATH = '/aliases';
1918

2019
/**

src/AnalyticsRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class AnalyticsRule
1010
public function __construct(string $ruleName, ApiCall $apiCall)
1111
{
1212
$this->ruleName = $ruleName;
13-
$this->apiCall = $apiCall;
13+
$this->apiCall = $apiCall;
1414
}
1515

1616
public function retrieve()

src/ApiCall.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
*/
3030
class ApiCall
3131
{
32-
3332
private const API_KEY_HEADER_NAME = 'X-TYPESENSE-API-KEY';
3433

3534
/**

0 commit comments

Comments
 (0)