Skip to content

Commit 829d07a

Browse files
committed
Test.
1 parent 79ebced commit 829d07a

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

.devtools/stop.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ echo "==============================="
2424
echo
2525

2626
info "Stopping previously started services, if any."
27-
killall -9 php >/dev/null 2>&1 || true
27+
kill -SIGKILL "$(ps aux | grep 'php -S' | grep -v grep | awk '{print $2}')" >/dev/null 2>&1 || true
2828
sleep 1
2929
pass "Services stopped."
3030

.github/workflows/scaffold-test.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,6 @@ jobs:
6767
path: ./.scaffold/.coverage-html
6868
if-no-files-found: error
6969

70-
- name: Upload coverage report to Codecov
71-
uses: codecov/codecov-action@v4
72-
if: ${{ env.CODECOV_TOKEN != '' }}
73-
with:
74-
directory: ./.scaffold/.coverage-html
75-
fail_ci_if_error: true
76-
token: ${{ secrets.CODECOV_TOKEN }}
77-
env:
78-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
79-
8070
scaffold-test-actions:
8171
runs-on: ubuntu-latest
8272

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ jobs:
7070
php-version: ${{ matrix.php-version }}
7171
extensions: gd, sqlite, pdo_sqlite
7272

73+
- name: Setup composer.json
74+
run: |
75+
rm composer.json
76+
mv composer.dist.json composer.json
77+
7378
- name: Assemble the codebase
7479
run: .devtools/assemble.sh
7580

.scaffold/Customizer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ protected function removeMakeCommandWrapper(): void {
315315

316316
/**
317317
* @throws \Exception
318+
*
319+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
320+
* @SuppressWarnings(PHPMD.NPathComplexity)
318321
*/
319322
public static function main(Event $event): void {
320323
$io = $event->getIO();
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Scaffold\Tests\Functional;
46

7+
use PHPUnit\Framework\Attributes\CoversClass;
58
use PHPUnit\Framework\TestCase;
9+
use Scaffold\Customizer;
610
use Symfony\Component\Filesystem\Filesystem;
711
use Symfony\Component\Filesystem\Path;
812
use Symfony\Component\Process\Process;
913

14+
#[CoversClass(Customizer::class)]
1015
class ScaffoldFunctionalTest extends TestCase {
16+
17+
protected Filesystem $filesystem;
18+
protected string $testDir;
19+
protected string $sourceDir;
20+
1121
protected function setUp(): void {
1222
parent::setUp();
1323

1424
$this->filesystem = new Filesystem();
15-
$this->testDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'test-' . time();
25+
$this->testDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'drupal-extension-scaffold-' . time();
26+
$this->sourceDir = Path::makeAbsolute('../../../..', __DIR__);
1627
$this->filesystem->mkdir($this->testDir);
1728
}
1829

19-
public function testBasic() {
20-
$working_dir = Path::makeAbsolute('../../../..', __DIR__);
30+
public function testBasic(): void {
2131
$process = new Process([
2232
'composer',
2333
'create-project',
2434
'--prefer-dist',
2535
'--no-interaction',
2636
'alexskrypnyk/drupal_extension_scaffold=@dev',
2737
'--repository',
28-
'{"type": "path", "url": "'. $working_dir .'", "options": {"symlink": false}}',
38+
'{"type": "path", "url": "' . $this->sourceDir . '", "options": {"symlink": false}}',
2939
$this->testDir,
3040
]);
3141
$process->setEnv([
3242
'DRUPAL_EXTENSION_SCAFFOLD_NAME' => 'Hello Extension',
3343
]);
3444
$status = $process->run();
3545
$this->assertEquals(0, $status);
36-
$process = new Process(['ls', '-al'], $this->testDir);
37-
$status = $process->run();
38-
$this->assertEquals(0, $status);
3946
$process = new Process(['./.devtools/assemble.sh'], $this->testDir);
4047
$status = $process->run();
4148
$this->assertEquals(0, $status);
@@ -45,9 +52,15 @@ public function testBasic() {
4552
$process = new Process(['./.devtools/provision.sh'], $this->testDir);
4653
$status = $process->run();
4754
$this->assertEquals(0, $status);
55+
56+
$this->assertFileExists($this->testDir . DIRECTORY_SEPARATOR . 'hello_extension.info.yml');
4857
}
4958

5059
protected function tearDown(): void {
5160
parent::tearDown();
61+
62+
$this->filesystem->chmod($this->testDir, 0700, 0000, true);
63+
$this->filesystem->remove($this->testDir);
5264
}
65+
5366
}

0 commit comments

Comments
 (0)