Skip to content

Commit a0d2508

Browse files
committed
#8 Add basic test
1 parent 3d7627c commit a0d2508

File tree

11 files changed

+170
-19
lines changed

11 files changed

+170
-19
lines changed

.github/dependabot.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: composer
4+
directory: "/"
5+
schedule:
6+
interval: monthly
7+
open-pull-requests-limit: 50
8+
labels:
9+
- "dependencies"
10+
reviewers:
11+
- lptn
12+
assignees:
13+
- ixdf-bot
14+
15+
- package-ecosystem: npm
16+
directory: "/"
17+
schedule:
18+
interval: monthly
19+
open-pull-requests-limit: 50
20+
labels:
21+
- "dependencies"
22+
reviewers:
23+
- hasan-wajahat
24+
assignees:
25+
- ixdf-bot

.github/run-tests.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: run-tests
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
os: [ ubuntu-latest ]
12+
php: [ 8.0, 8.1 ]
13+
laravel: [ 8.* ]
14+
dependency-version: [ prefer-stable ]
15+
include:
16+
- laravel: 8.*
17+
testbench: 6.*
18+
19+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v2
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
30+
coverage: none
31+
32+
- name: Setup problem matchers
33+
run: |
34+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
35+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
36+
37+
- name: Install dependencies
38+
run: |
39+
composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_PASSWORD }}"
40+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
41+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
42+
env:
43+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
44+
45+
- name: Execute tests
46+
run: composer test

README.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,6 @@ Please see [Releases](https://github.com/InteractionDesignFoundation/nova-unlaye
7575
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
7676

7777

78-
### Compiling Assets
79-
80-
```bash
81-
# Compile and minify your assets:
82-
npm run prod
83-
84-
# Compile your assets for local development:
85-
npm run dev
86-
87-
# Run the NPM "watch" command to auto-compile your assets when they are changed:
88-
npm run watch
89-
```
90-
91-
9278
## License
9379

9480
The MIT License (MIT). Please see [License File](LICENSE) for more information.

composer.json

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,28 @@
88
],
99
"license": "MIT",
1010
"require": {
11-
"php": "^8.0",
12-
"ext-json": "*"
11+
"php": ">=8.0",
12+
"ext-json": "*",
13+
"laravel/nova": "^3.0"
1314
},
14-
"require-dev": {},
15+
"require-dev": {
16+
"mockery/mockery": "^1.4",
17+
"orchestra/testbench": "^6.0",
18+
"phpunit/phpunit": "^9.4"
19+
},
20+
"repositories": [
21+
{
22+
"type": "composer", "url": "https://nova.laravel.com"
23+
}
24+
],
1525
"autoload": {
1626
"psr-4": {
1727
"InteractionDesignFoundation\\NovaUnlayerField\\": "src/"
1828
}
1929
},
2030
"autoload-dev": {
2131
"psr-4": {
22-
"Tests\\": "tests/"
32+
"InteractionDesignFoundation\\NovaUnlayerField\\Tests\\": "tests"
2333
}
2434
},
2535
"extra": {
@@ -33,5 +43,8 @@
3343
"sort-packages": true
3444
},
3545
"minimum-stability": "dev",
36-
"prefer-stable": true
46+
"prefer-stable": true,
47+
"scripts": {
48+
"test": "phpunit"
49+
}
3750
}

docs/CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Compiling Assets
2+
3+
```bash
4+
# Install npm dependencies
5+
npm install
6+
```
7+
8+
```bash
9+
# Compile and minify your assets:
10+
npm run prod
11+
12+
# Compile your assets for local development:
13+
npm run dev
14+
15+
# Run the NPM "watch" command to auto-compile your assets when they are changed:
16+
npm run watch
17+
```
18+
19+
## Run tests
20+
21+
```bash
22+
composer test
23+
```

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"private": false,
3+
"engines": {
4+
"node": "^14.0"
5+
},
36
"scripts": {
47
"dev": "npm run development",
58
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",

phpunit.xml.dist

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.4/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src/</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="IxDF Test Suite">
10+
<directory>tests</directory>
11+
</testsuite>
12+
</testsuites>
13+
<php>
14+
</php>
15+
</phpunit>

src/Unlayer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ final public function savingCallback(?callable $callback): static
5656
*/
5757
final public function html(string | callable $html): static
5858
{
59+
/** @var string $html */
5960
$html = is_callable($html)
6061
? $html()
6162
: $html;

tests/.gitkeep

Whitespace-only changes.

tests/TestCase.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace InteractionDesignFoundation\NovaUnlayerField\Tests;
4+
5+
use InteractionDesignFoundation\NovaUnlayerField\ServiceProvider;
6+
use Orchestra\Testbench\TestCase as OrchestraTestCase;
7+
8+
abstract class TestCase extends OrchestraTestCase
9+
{
10+
public function setUp(): void
11+
{
12+
parent::setUp();
13+
}
14+
15+
protected function getPackageProviders($app)
16+
{
17+
return [
18+
ServiceProvider::class,
19+
];
20+
}
21+
}

0 commit comments

Comments
 (0)