Skip to content

Commit eb938e3

Browse files
authored
Merge pull request #3 from laravelcm/subscribe-test
Add Pest and setup subscribe test
2 parents 295981d + 6e6eea6 commit eb938e3

File tree

12 files changed

+126
-31
lines changed

12 files changed

+126
-31
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
},
5555
"autoload-dev": {
5656
"psr-4": {
57-
"Tests\\": "tests"
57+
"Tests\\": "tests/src",
58+
"Tests\\Database\\Factories\\": "tests/database/factories"
5859
}
5960
},
6061
"scripts": {
File renamed without changes.

phpunit.xml.dist

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
colors="true"
66
backupStaticProperties="true">
77
<testsuites>
8-
<testsuite name="Test Suite">
8+
<testsuite name="Subscription Test Suite">
99
<directory suffix="Test.php">./tests/Feature</directory>
1010
</testsuite>
1111
</testsuites>
@@ -15,11 +15,11 @@
1515
</exclude>
1616
</source>
1717
<php>
18-
<server name="APP_ENV" value="testing"/>
19-
<server name="CACHE_DRIVER" value="array"/>
20-
<server name="SESSION_DRIVER" value="array"/>
21-
<server name="QUEUE_CONNECTION" value="sync"/>
22-
<server name="DB_CONNECTION" value="sqlite"/>
23-
<server name="DB_DATABASE" value=":memory:"/>
18+
<env name="APP_ENV" value="testing"/>
19+
<env name="CACHE_DRIVER" value="array"/>
20+
<env name="SESSION_DRIVER" value="array"/>
21+
<env name="QUEUE_CONNECTION" value="sync"/>
22+
<env name="DB_CONNECTION" value="sqlite"/>
23+
<env name="DB_DATABASE" value=":memory:"/>
2424
</php>
2525
</phpunit>

src/SubscriptionServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class SubscriptionServiceProvider extends PackageServiceProvider
1212
public function configurePackage(Package $package): void
1313
{
1414
$package->name('laravel-subscriptions')
15-
->hasConfigFile();
15+
->hasConfigFile('laravel-subscriptions');
1616
}
1717

1818
public function bootingPackage(): void

src/Traits/HasPlanSubscriptions.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
trait HasPlanSubscriptions
1515
{
16-
abstract public function morphMany(string $related, string $name, ?string $type, ?string $id, ?string $localKey = null): MorphMany;
17-
1816
protected static function bootHasSubscriptions(): void
1917
{
2018
static::deleted(function ($plan): void {

tests/Feature/ExampleTest.php

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

tests/Feature/SubscribeTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Tests\Models\User;
6+
7+
it('User model has plan subscription trait or implement subscription methods', function (): void {
8+
expect(User::factory()->create())
9+
->toHaveMethods([
10+
'activePlanSubscriptions',
11+
'planSubscription',
12+
'planSubscriptions',
13+
'newPlanSubscription',
14+
'subscribedPlans',
15+
'subscribedTo',
16+
]);
17+
});

tests/Pest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
declare(strict_types=1);
44

5-
use Illuminate\Foundation\Testing\RefreshDatabase;
65
use Tests\TestCase;
76

8-
uses(TestCase::class, RefreshDatabase::class)->in('Feature');
7+
uses(TestCase::class)->in('Feature');
98

109
expect()->extend('toBeOne', fn () => $this->toBe(1));

tests/TestCase.php

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Database\Factories;
6+
7+
use Tests\Models\User;
8+
9+
final class UserFactory extends \Orchestra\Testbench\Factories\UserFactory
10+
{
11+
public function modelName(): string
12+
{
13+
return User::class;
14+
}
15+
}

0 commit comments

Comments
 (0)