Skip to content

Commit 8e4f571

Browse files
authored
fix: all test suites (#148)
* fix: test suite * fix: migrating phpunit config * fix: I want to see how much is failing * fix: just trying something * fix: widen the versions tested against * fix: not ready for 8.4 * fix: it doesn't fail in Windows 🤔 * fix: carbon dependency * fix: make it verbose * fix: make it verbose * fix: I don't think it will change anything, but who knows * fix: debug what's happening under the hood * fix: why the hello yauzl is failing on prefer-lowest 😡 * fix: clean zip maybe ? * Fix styling * fix: clean zip maybe ? * fix: fixed? * fix: phpstan (level 4) * fix: cleaning * feat: composer qa * fix: renamed test --------- Co-authored-by: SRWieZ <[email protected]>
1 parent d5e7c28 commit 8e4f571

19 files changed

+465
-374
lines changed

.github/workflows/phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
paths:
66
- '**.php'
7-
- 'phpstan.neon.dist'
7+
- '../../phpstan.neon'
88

99
jobs:
1010
phpstan:

.github/workflows/run-tests.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,26 @@ jobs:
1010
test:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
13-
fail-fast: true
13+
fail-fast: false
1414
matrix:
1515
os: [ubuntu-latest, windows-latest]
16-
php: [8.2, 8.1]
17-
laravel: [10.*]
16+
php: [8.2, 8.1, 8.3]
17+
laravel: [10.*, 11.*]
1818
stability: [prefer-lowest, prefer-stable]
1919
include:
2020
- laravel: 10.*
2121
testbench: ^8.18
2222
carbon: ^2.67
23+
laravel-package-tools: ^1.16
24+
collision: 7.*
25+
- laravel: 11.*
26+
testbench: 9.*
27+
carbon: "^2.67|^3.0"
28+
laravel-package-tools: ^1.16
29+
collision: ^8.1.1
30+
exclude:
31+
- laravel: 11.*
32+
php: 8.1
2333

2434
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
2535

@@ -41,7 +51,7 @@ jobs:
4151
4252
- name: Install dependencies
4353
run: |
44-
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
54+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" "spatie/laravel-package-tools:${{ matrix.laravel-package-tools }}" "nunomaduro/collision:${{ matrix.collision }}" --no-interaction --no-update
4555
composer update --${{ matrix.stability }} --no-interaction
4656
4757
- name: List Installed Dependencies

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ composer.lock
55
coverage
66
docs
77
phpunit.xml
8-
phpstan.neon
98
vendor
109
node_modules
1110
resources/js/*.log

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"illuminate/contracts": "^10.0|^11.0",
3636
"laravel/prompts": "^0.1.1|^0.2|^0.3",
3737
"nativephp/laravel": "*",
38-
"nativephp/php-bin": "^0.5",
38+
"nativephp/php-bin": "^0.5.1",
3939
"spatie/laravel-package-tools": "^1.14.0"
4040
},
4141
"require-dev": {
@@ -62,6 +62,11 @@
6262
}
6363
},
6464
"scripts": {
65+
"qa": [
66+
"@composer format",
67+
"@composer analyse",
68+
"@composer test"
69+
],
6570
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
6671
"analyse": "vendor/bin/phpstan analyse",
6772
"test": "vendor/bin/pest",

phpstan-baseline.neon

Whitespace-only changes.
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
includes:
2-
- phpstan-baseline.neon
3-
41
parameters:
52
level: 4
63
paths:
@@ -10,5 +7,4 @@ parameters:
107
tmpDir: build/phpstan
118
checkOctaneCompatibility: true
129
checkModelProperties: true
13-
checkMissingIterableValueType: false
1410

phpunit.xml.dist

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
5-
backupGlobals="false"
6-
bootstrap="vendor/autoload.php"
7-
colors="true"
8-
processIsolation="false"
9-
stopOnFailure="false"
10-
executionOrder="random"
11-
failOnWarning="true"
12-
failOnRisky="true"
13-
failOnEmptyTestSuite="true"
14-
beStrictAboutOutputDuringTests="true"
15-
cacheDirectory=".phpunit.cache"
16-
backupStaticProperties="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
backupGlobals="false"
5+
bootstrap="vendor/autoload.php"
6+
colors="true"
7+
processIsolation="false"
8+
stopOnFailure="false"
9+
executionOrder="random"
10+
failOnWarning="true"
11+
failOnRisky="true"
12+
failOnEmptyTestSuite="true"
13+
beStrictAboutOutputDuringTests="true"
14+
cacheDirectory=".phpunit.cache"
15+
backupStaticProperties="false"
1716
>
1817
<testsuites>
1918
<testsuite name="Native Test Suite">
2019
<directory>tests</directory>
2120
</testsuite>
2221
</testsuites>
2322
<coverage>
24-
<include>
25-
<directory suffix=".php">./src</directory>
26-
</include>
2723
<report>
2824
<html outputDirectory="build/coverage"/>
2925
<text outputFile="build/coverage.txt"/>
@@ -33,4 +29,9 @@
3329
<logging>
3430
<junit outputFile="build/report.junit.xml"/>
3531
</logging>
32+
<source>
33+
<include>
34+
<directory suffix=".php">./src</directory>
35+
</include>
36+
</source>
3637
</phpunit>

resources/js/electron-plugin/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module.exports = {
33
preset: 'ts-jest',
44
testEnvironment: 'node',
55
moduleNameMapper: {
6-
"electron": "<rootDir>/mocks/electron.ts",
6+
"^electron$": "<rootDir>/mocks/electron.ts",
77
}
88
};
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
export default {}
1+
module.exports = {
2+
app: {
3+
getPath: jest.fn().mockReturnValue('path'),
4+
isPackaged: jest.fn().mockResolvedValue(function () {
5+
console.log('isPackaged');
6+
return false;
7+
})
8+
},
9+
powerMonitor: {
10+
addListener: jest.fn()
11+
}
12+
}

resources/js/electron-plugin/tests/endpoints/clipboard.test.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import startAPIServer, { APIProcess } from "../../src/server/api";
2-
import axios, { AxiosError } from "axios";
2+
import axios from "axios";
33
import electron from "electron";
44

55
let apiServer: APIProcess;
@@ -10,18 +10,20 @@ const mockReadImage = {
1010
};
1111

1212
jest.mock('electron', () => ({
13-
clipboard: {
14-
readText: jest.fn(() => 'clipboard text'),
15-
readHTML: jest.fn(() => 'clipboard html'),
16-
readImage: jest.fn(() => mockReadImage),
17-
writeText: jest.fn(),
18-
writeHTML: jest.fn(),
19-
writeImage: jest.fn(),
20-
clear: jest.fn(),
21-
},
22-
nativeImage: {
23-
createFromDataURL: jest.fn(() => 'native image'),
24-
}
13+
...jest.requireActual('electron'),
14+
15+
clipboard: {
16+
readText: jest.fn(() => 'clipboard text'),
17+
readHTML: jest.fn(() => 'clipboard html'),
18+
readImage: jest.fn(() => mockReadImage),
19+
writeText: jest.fn(),
20+
writeHTML: jest.fn(),
21+
writeImage: jest.fn(),
22+
clear: jest.fn(),
23+
},
24+
nativeImage: {
25+
createFromDataURL: jest.fn(() => 'native image'),
26+
}
2527
}));
2628

2729
describe('Clipboard test', () => {
@@ -65,7 +67,7 @@ describe('Clipboard test', () => {
6567

6668
it('returns an error when trying to write an invalid data URL as image', async () => {
6769
try {
68-
const response = await axios.post('/clipboard/image', {
70+
await axios.post('/clipboard/image', {
6971
image: 'new image data URL',
7072
});
7173
} catch (error) {
@@ -76,7 +78,7 @@ describe('Clipboard test', () => {
7678
it('can write new images to clipboard', async () => {
7779
const exampleImage = 'example image url';
7880

79-
const response = await axios.post('/clipboard/image', {
81+
await axios.post('/clipboard/image', {
8082
image: exampleImage,
8183
});
8284

0 commit comments

Comments
 (0)