Skip to content

Commit 3cb397f

Browse files
committed
migrate tests from electron repo
1 parent 99f2e42 commit 3cb397f

File tree

8 files changed

+49
-174
lines changed

8 files changed

+49
-174
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.idea
22
.phpunit.cache
3-
./build
3+
build
44
composer.lock
55
coverage
66
docs

build/report.junit.xml

Lines changed: 0 additions & 116 deletions
This file was deleted.

electron-repo/tests/Unit/Traits/CopiesCertificateAuthorityTest.php

Lines changed: 0 additions & 55 deletions
This file was deleted.
File renamed without changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
use Native\Electron\ElectronServiceProvider;
4+
use Native\Electron\Traits\CopiesCertificateAuthority;
5+
use Symfony\Component\Filesystem\Filesystem;
6+
use Symfony\Component\Filesystem\Path;
7+
8+
it('can copy the default CA certificate from php-bin', function ($mock) {
9+
10+
$certificatePath = Path::join(ElectronServiceProvider::ELECTRON_PATH, 'resources', 'cacert.pem');
11+
(new Filesystem)->remove($certificatePath);
12+
13+
expect($certificatePath)->not->toBeFile();
14+
15+
$mock->run();
16+
17+
expect($certificatePath)->toBeFile();
18+
19+
})->with([
20+
// Empty class with the CopiesCertificateAuthority trait
21+
new class
22+
{
23+
use CopiesCertificateAuthority;
24+
25+
public function run()
26+
{
27+
$this->copyCertificateAuthorityCertificate();
28+
}
29+
},
30+
]);

electron-repo/tests/Unit/Traits/HasPreAndPostProcessingTest.php renamed to tests/Build/HasPreAndPostProcessingTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
namespace Native\Electron\Tests\Unit\Traits;
4-
53
use Illuminate\Support\Facades\Config;
64
use Native\Electron\Traits\HasPreAndPostProcessing;
75

tests/Pest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
<?php
22

33
use Native\Laravel\Tests\TestCase;
4+
use Symfony\Component\Filesystem\Filesystem;
45

56
uses(TestCase::class)->in(__DIR__);
7+
8+
function testsDir(string $path = ''): string
9+
{
10+
return __DIR__.'/'.$path;
11+
}
12+
13+
function createFiles(array|string $paths): array
14+
{
15+
$paths = (array) $paths;
16+
$filesystem = new Filesystem;
17+
18+
foreach ($paths as $path) {
19+
$filesystem->dumpFile($path, '');
20+
}
21+
22+
return $paths;
23+
}

0 commit comments

Comments
 (0)