Skip to content

Commit 2cd36d5

Browse files
committed
Add test for ComposerMustBeValid
1 parent 545dc62 commit 2cd36d5

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Domain\Insights\Composer;
6+
7+
use NunoMaduro\PhpInsights\Domain\Collector;
8+
use NunoMaduro\PhpInsights\Domain\Insights\Composer\ComposerMustBeValid;
9+
use PHPUnit\Framework\TestCase;
10+
11+
final class ComposerMustBeValidTest extends TestCase
12+
{
13+
public function testComposerIsNotValid(): void
14+
{
15+
$collector = new Collector(__DIR__ . '/Fixtures/Fresh');
16+
$insight = new ComposerMustBeValid($collector, []);
17+
18+
self::assertTrue($insight->hasIssue());
19+
self::assertIsArray($insight->getDetails());
20+
self::assertContains('composer.json: The property name is required', $insight->getDetails());
21+
self::assertContains('composer.json: The property description is required', $insight->getDetails());
22+
self::assertContains('composer.json: No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.', $insight->getDetails());
23+
}
24+
25+
public function testComposerIsValid(): void
26+
{
27+
$collector = new Collector(__DIR__ . '/Fixtures/Valid');
28+
$insight = new ComposerMustBeValid($collector, []);
29+
30+
self::assertFalse($insight->hasIssue());
31+
}
32+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "dummy/foo-package",
3+
"description": "Hey look at me",
4+
"type": "project",
5+
"license": "MIT",
6+
"require": {}
7+
}

0 commit comments

Comments
 (0)