Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a8f1685

Browse files
thekonzmsonowal
authored andcommittedApr 16, 2021
add some testing scaffolding
1 parent af4bc22 commit a8f1685

File tree

10 files changed

+131
-1
lines changed

10 files changed

+131
-1
lines changed
 

‎.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true

‎.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
build-test:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: php-actions/composer@v1
12+
- name: PHPUnit Tests
13+
uses: php-actions/phpunit@v9
14+
with:
15+
configuration: test/phpunit.xml

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea/
22
composer.lock
33
/vendor
4+
/.phpunit.result.cache

‎CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Contribution Guide
2+
3+
1. Make sure to include unit tests
4+
5+
## Unit tests
6+
7+
You can run unit tests locally by executing `make` once
8+
and then `make test` for consecutive runs (you will need to install docker before).

‎Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM composer AS composer
2+
FROM php:7.2-cli
3+
COPY --from=composer /usr/bin/composer /usr/bin/composer
4+
WORKDIR /app
5+
6+
RUN apt-get update && \
7+
apt-get install -y zip unzip git

‎Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
all: build install test
2+
3+
test:
4+
docker run -it -v $(shell pwd):/app laravel-scout-mysql-driver vendor/bin/phpunit
5+
6+
install:
7+
docker run -it -v $(shell pwd):/app laravel-scout-mysql-driver composer install
8+
9+
bash:
10+
docker run -it -v $(shell pwd):/app -it laravel-scout-mysql-driver bash
11+
12+
build:
13+
docker build -t laravel-scout-mysql-driver:latest .

‎composer.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
"email": "matt@yabhq.com"
1313
}
1414
],
15-
"minimum-stability": "dev",
1615
"require": {
1716
"php": "^7.2|^8.0",
1817
"laravel/scout": "~6.0|~7.0|~8.0"
1918
},
19+
"require-dev": {
20+
"phpunit/phpunit": "8.5.x-dev",
21+
"laravel/framework": "5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0",
22+
"mockery/mockery": "^1.3"
23+
},
2024
"autoload": {
2125
"psr-4": {
2226
"Yab\\MySQLScout\\": "src/"
@@ -25,6 +29,11 @@
2529
"src/helpers.php"
2630
]
2731
},
32+
"autoload-dev": {
33+
"psr-4": {
34+
"Tests\\": "tests/"
35+
}
36+
},
2837
"extra": {
2938
"laravel": {
3039
"providers": [

‎phpunit.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
>
7+
<testsuites>
8+
<testsuite name="Unit">
9+
<directory suffix="Test.php">./tests</directory>
10+
</testsuite>
11+
</testsuites>
12+
<filter>
13+
<whitelist processUncoveredFilesFromWhitelist="true">
14+
<directory suffix=".php">./src</directory>
15+
</whitelist>
16+
</filter>
17+
</phpunit>

‎tests/TestCase.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
4+
namespace Tests;
5+
6+
7+
use Illuminate\Config\Repository;
8+
use PHPUnit\Framework\TestCase as BaseTestCase;
9+
10+
class TestCase extends BaseTestCase
11+
{
12+
protected function setUp(): void
13+
{
14+
parent::setUp();
15+
16+
$config = new Repository([
17+
'scout' => [
18+
'mysql' => [
19+
'mode' => 'NATURAL_LANGUAGE',
20+
'model_directories' => [__DIR__],
21+
'min_search_length' => 0,
22+
'min_fulltext_search_length' => 4,
23+
'min_fulltext_search_fallback' => 'LIKE',
24+
'query_expansion' => false
25+
]
26+
]
27+
]);
28+
29+
app()->instance('config', $config);
30+
}
31+
}

‎tests/TestModel.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
4+
namespace Tests;
5+
6+
7+
use Illuminate\Database\Eloquent\Model;
8+
use Laravel\Scout\Searchable;
9+
10+
class TestModel extends Model
11+
{
12+
use Searchable;
13+
14+
public function toSearchableArray()
15+
{
16+
return [
17+
'first_name' => 'Steve',
18+
'last_name' => 'Broski',
19+
];
20+
}
21+
}

0 commit comments

Comments
 (0)
This repository has been archived.