Skip to content

Commit 59bb9fe

Browse files
committed
Add tests
1 parent 57adcad commit 59bb9fe

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

phpunit.xml.dist

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5+
backupGlobals="false"
6+
backupStaticAttributes="false"
7+
bootstrap="vendor/autoload.php"
8+
colors="true"
9+
convertErrorsToExceptions="true"
10+
convertNoticesToExceptions="true"
11+
convertWarningsToExceptions="true"
12+
processIsolation="false"
13+
stopOnFailure="false"
14+
executionOrder="random"
15+
failOnWarning="true"
16+
failOnRisky="true"
17+
failOnEmptyTestSuite="true"
18+
beStrictAboutOutputDuringTests="true"
19+
verbose="true"
20+
>
21+
<testsuites>
22+
<testsuite name="VendorName Test Suite">
23+
<directory>tests</directory>
24+
</testsuite>
25+
</testsuites>
26+
<coverage>
27+
<include>
28+
<directory suffix=".php">./src</directory>
29+
</include>
30+
<report>
31+
<html outputDirectory="build/coverage"/>
32+
<text outputFile="build/coverage.txt"/>
33+
<clover outputFile="build/logs/clover.xml"/>
34+
</report>
35+
</coverage>
36+
<logging>
37+
<junit outputFile="build/report.junit.xml"/>
38+
</logging>
39+
</phpunit>

tests/ExampleTest.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace :vendor_namespace\:package_class_name\Tests;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use :vendor_namespace\:package_class_name\:package_class_name;
7+
8+
class :package_class_nameTest extends TestCase
9+
{
10+
/** @test */
11+
12+
public function it_can_getPackageDetail()
13+
{
14+
$array = (new :package_class_name)->getPackageDetail();
15+
16+
$this->assertEquals([
17+
'author' => [
18+
'name' => ':author_name',
19+
'username' => ':author_username',
20+
'email' => ':author_email',
21+
],
22+
'vendor' => [
23+
'name' => ':vendor_name',
24+
'slug' => ':vendor_slug',
25+
],
26+
'package' => [
27+
'name' => ':package_name',
28+
'slug' => ':package_slug',
29+
'description' => ':package_description',
30+
],
31+
], $array);
32+
}
33+
}

tests/TestbenchTestCase.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace :vendor_namespace\:package_class_name\Tests;
4+
5+
use Orchestra\Testbench\TestCase as Testbench;
6+
7+
abstract class TestbenchTestCase extends Testbench
8+
{
9+
public function setUp(): void
10+
{
11+
parent::setUp();
12+
}
13+
14+
public function tearDown(): void
15+
{
16+
parent::tearDown();
17+
}
18+
19+
protected function getPackageProviders($app): array
20+
{
21+
return [':vendor_namespace\:package_class_name\:package_class_nameServiceProvider'];
22+
}
23+
}

0 commit comments

Comments
 (0)