Skip to content

Commit

Permalink
- Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dash8x committed Aug 20, 2024
1 parent 718b600 commit 9295f0c
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"orchestra/testbench": "^7.0 || ^8.0 || ^9.0",
"phpunit/phpunit": "^9.5 || ^10.5",
"laravel/pint": "^1.15",
"javaabu/auth": "^1.7"
"javaabu/auth": "^1.11"
},
"suggest": {
"javaabu/auth": "Required for login and registration"
Expand Down
18 changes: 17 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

namespace Javaabu\MobileVerification\Tests;

use Composer\Semver\VersionParser;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Artisan;
use Biscolab\ReCaptcha\Facades\ReCaptcha;
use Javaabu\Helpers\HelpersServiceProvider;
use Illuminate\Support\Facades\Notification;
use Laravel\Passport\PassportServiceProvider;
use Orchestra\Testbench\TestCase as BaseTestCase;
use Javaabu\Activitylog\ActivitylogServiceProvider;
use Spatie\MediaLibrary\MediaLibraryServiceProvider;
use Javaabu\SmsNotifications\SmsNotificationsServiceProvider;
use Javaabu\MobileVerification\MobileVerificationServiceProvider;
use Javaabu\MobileVerification\Tests\TestSupport\Providers\TestServiceProvider;
Expand All @@ -27,13 +30,26 @@ public function setUp(): void

View::addLocation(__DIR__ . '/TestSupport/views');

// call sanctum install:api
if (empty(glob($this->app->databasePath('migrations/*_create_media_table.php')))) {
Artisan::call('vendor:publish', [
'--provider' => 'Spatie\\MediaLibrary\\MediaLibraryServiceProvider',
'--tag' => self::isMediaLibrary10() ? 'migrations' : 'medialibrary-migrations',
]);

Artisan::call('migrate');
}
}

public static function isMediaLibrary10(): bool
{
return \Composer\InstalledVersions::satisfies(new VersionParser(), 'spatie/laravel-medialibrary', '10.*');
}

protected function getPackageProviders($app)
{
return [
MobileVerificationServiceProvider::class,
MediaLibraryServiceProvider::class,
TestServiceProvider::class,
SmsNotificationsServiceProvider::class,
HelpersServiceProvider::class,
Expand Down
10 changes: 10 additions & 0 deletions tests/TestSupport/Controllers/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,14 @@ public function enableReCaptcha(): bool
{
return false;
}

public function guardName(): string
{
return 'web';
}

public function userType(): \Javaabu\Auth\User
{
return new User();
}
}
42 changes: 41 additions & 1 deletion tests/TestSupport/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Http\RedirectResponse;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Javaabu\Auth\User as Authenticatable;
use Javaabu\MobileVerification\Contracts\HasMobileNumber;
use Javaabu\MobileVerification\Traits\InteractsWithMobileNumbers;
use Javaabu\MobileVerification\Tests\TestSupport\Factories\UserFactory;
Expand Down Expand Up @@ -46,4 +46,44 @@ public function redirectToMobileVerificationUrl(): RedirectResponse
{
return to_route('mobile-verifications.login.create');
}

public function getAdminUrlAttribute(): string
{
// TODO: Implement getAdminUrlAttribute() method.
}

public function passwordUpdateUrl()
{
// TODO: Implement passwordUpdateUrl() method.
}

public function guardName(): string
{
return 'web';
}

public function homeUrl()
{
// TODO: Implement homeUrl() method.
}

public function loginUrl()
{
// TODO: Implement loginUrl() method.
}

public function getRouteForPasswordReset()
{
// TODO: Implement getRouteForPasswordReset() method.
}

public function getRouteForEmailVerification()
{
// TODO: Implement getRouteForEmailVerification() method.
}

public function inactiveNoticeUrl()
{
// TODO: Implement inactiveNoticeUrl() method.
}
}
1 change: 1 addition & 0 deletions tests/TestSupport/database/create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function up()
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->string('status')->index();
$table->timestamps();
$table->softDeletes();
});
Expand Down

0 comments on commit 9295f0c

Please sign in to comment.