Skip to content

Commit

Permalink
Merge pull request #5815 from thedevdojo/1.6-l10-failing-tests
Browse files Browse the repository at this point in the history
Fix failing tests for Laravel 10
  • Loading branch information
tnylea committed Nov 10, 2023
2 parents 2e0db75 + 167daa1 commit 19286d1
Show file tree
Hide file tree
Showing 26 changed files with 136 additions and 141 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ jobs:

# Run phpunit tests
- name: Run tests
run: ./vendor/bin/phpunit
run: ./vendor/bin/phpunit --no-coverage

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ build
.lock
composer.lock
.phpunit.result.cache
.phpunit.cache
114 changes: 62 additions & 52 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,65 @@
{
"name": "tcg/voyager",
"description": "A Laravel Admin Package for The Control Group to make your life easier and steer your project in the right direction",
"keywords": ["laravel", "admin", "panel"],
"license": "MIT",
"homepage": "https://voyager.devdojo.com/",
"support": {
"issues": "https://github.com/the-control-group/voyager/issues",
"source": "https://github.com/the-control-group/voyager"
},
"authors": [
{
"name": "Tony Lea",
"email": "tony.lea@thecontrolgroup.com"
}
],
"require": {
"php": "^7.3|^7.4|^8.0",
"illuminate/support": "~8.0|~9.0|~10.0",
"intervention/image": "^2.4",
"doctrine/dbal": "^3.1|^3.5",
"laravel/ui": ">=1.0",
"arrilot/laravel-widgets": "^3.7",
"league/flysystem": "~1.1|~2.0|~3.0",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpcov": ">=6.0",
"phpunit/phpunit": ">=8.0",
"laravel/framework": "~8.0|~9.0|~10.0",
"orchestra/testbench": ">=6.0",
"laravel/browser-kit-testing": ">=6.1.0",
"orchestra/testbench-browser-kit": ">=4.0"
},
"autoload": {
"psr-4": {
"TCG\\Voyager\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"TCG\\Voyager\\Tests\\": "tests/",
"TCG\\Voyager\\Tests\\Database\\Factories\\": "tests/database/factories/"
}
},
"minimum-stability": "stable",
"extra": {
"laravel": {
"providers": [
"TCG\\Voyager\\VoyagerServiceProvider",
"TCG\\Voyager\\Providers\\VoyagerDummyServiceProvider"
]
}
"name": "tcg/voyager",
"description": "A Laravel Admin Package for The Control Group to make your life easier and steer your project in the right direction",
"keywords": [
"laravel",
"admin",
"panel"
],
"license": "MIT",
"homepage": "https://voyager.devdojo.com/",
"support": {
"issues": "https://github.com/the-control-group/voyager/issues",
"source": "https://github.com/the-control-group/voyager"
},
"authors": [
{
"name": "Tony Lea",
"email": "tony.lea@thecontrolgroup.com"
}
],
"require": {
"php": "^7.3|^7.4|^8.0|^8.1|^8.2",
"illuminate/support": "~8.0|~9.0|~10.0",
"intervention/image": "^2.7",
"doctrine/dbal": "^3.1|^3.5",
"laravel/ui": ">=1.0",
"arrilot/laravel-widgets": "^3.7",
"league/flysystem": "~1.1|~2.0|~3.0",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpcov": ">=6.0",
"phpunit/phpunit": ">=8.0",
"laravel/framework": "~8.0|~9.0|~10.0",
"orchestra/testbench": ">=6.0",
"laravel/browser-kit-testing": ">=6.1.0",
"orchestra/testbench-browser-kit": ">=4.0"
},
"autoload": {
"psr-4": {
"TCG\\Voyager\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"TCG\\Voyager\\Tests\\": "tests/",
"TCG\\Voyager\\Tests\\Database\\Factories\\": "tests/database/factories/",
"Database\\Seeders\\": "vendor/orchestra/testbench-core/laravel/database/seeders"
}
},
"minimum-stability": "stable",
"extra": {
"laravel": {
"providers": [
"TCG\\Voyager\\VoyagerServiceProvider",
"TCG\\Voyager\\Providers\\VoyagerDummyServiceProvider"
]
}
},
"scripts": {
"post-autoload-dump": [
"@php vendor/bin/testbench package:discover --ansi"
]
}
}
58 changes: 26 additions & 32 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="Voyager Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" />
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false" showOnlySummary="true"/>
</logging>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_DEBUG" value="true"/>
<env name="APP_URL" value="http://localhost"/>
<env name="APP_KEY" value="base64:M1igrxNfAWlVGyxxDholHqvVqvtPjAzCoJ+2/ILAVPw="/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="tests/bootstrap.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="php://stdout" showUncoveredFiles="false" showOnlySummary="true"/>
</report>
</coverage>
<testsuites>
<testsuite name="Voyager Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_DEBUG" value="true"/>
<env name="APP_URL" value="http://localhost"/>
<env name="APP_KEY" value="base64:M1igrxNfAWlVGyxxDholHqvVqvtPjAzCoJ+2/ILAVPw="/>
</php>
<source>
<include>
<directory suffix=".php">./src/</directory>
</include>
</source>
</phpunit>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Category;
use TCG\Voyager\Models\DataRow;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\DataRow;
use TCG\Voyager\Models\DataType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\DataRow;
use TCG\Voyager\Models\DataType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
use TCG\Voyager\Models\Role;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\DataRow;
use TCG\Voyager\Models\DataType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\DataType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Menu;
use TCG\Voyager\Models\MenuItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Menu;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Permission;
use TCG\Voyager\Models\Role;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Permission;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Role;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Setting;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Category;
use TCG\Voyager\Models\DataType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class VoyagerDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
* Run the database seeders.
*
* @return void
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class VoyagerDummyDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
* Run the database seeders.
*
* @return void
*/
Expand Down
34 changes: 2 additions & 32 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Illuminate\Support\Composer;
use Symfony\Component\Console\Input\InputOption;
use TCG\Voyager\Providers\VoyagerDummyServiceProvider;
use TCG\Voyager\Seed;
use TCG\Voyager\VoyagerServiceProvider;

class InstallCommand extends Command
Expand Down Expand Up @@ -47,7 +46,6 @@ public function __construct(Composer $composer)
$this->composer = $composer;
$this->composer->setWorkingPath(base_path());

$this->seedFolder = Seed::getFolderName();
}

protected function getOptions()
Expand Down Expand Up @@ -89,7 +87,7 @@ public function handle(Filesystem $filesystem)
$this->info('Publishing the Voyager assets, database, and config files');

// Publish only relevant resources on install
$tags = ['seeds'];
$tags = ['seeders'];

$this->call('vendor:publish', ['--provider' => VoyagerServiceProvider::class, '--tag' => $tags]);

Expand Down Expand Up @@ -125,25 +123,14 @@ public function handle(Filesystem $filesystem)

if ($this->option('with-dummy')) {
$this->info('Publishing dummy content');
$tags = ['dummy_seeds', 'dummy_content', 'dummy_config', 'dummy_migrations'];
$tags = ['dummy_seeders', 'dummy_content', 'dummy_config', 'dummy_migrations'];
$this->call('vendor:publish', ['--provider' => VoyagerDummyServiceProvider::class, '--tag' => $tags]);

$this->addNamespaceIfNeeded(
collect($filesystem->files("{$publishablePath}/database/dummy_seeds/")),
$filesystem
);
} else {
$this->call('vendor:publish', ['--provider' => VoyagerServiceProvider::class, '--tag' => ['config', 'voyager_avatar']]);
}

$this->addNamespaceIfNeeded(
collect($filesystem->files("{$publishablePath}/database/seeds/")),
$filesystem
);

$this->info('Dumping the autoloaded files and reloading all new files');
$this->composer->dumpAutoloads();
require_once base_path('vendor/autoload.php');

$this->info('Seeding data into the database');
$this->call('db:seed', ['--class' => 'VoyagerDatabaseSeeder', '--force' => $this->option('force')]);
Expand All @@ -162,21 +149,4 @@ public function handle(Filesystem $filesystem)
$this->info('Successfully installed Voyager! Enjoy');
}

private function addNamespaceIfNeeded($seeds, Filesystem $filesystem)
{
if ($this->seedFolder != 'seeders') {
return;
}

$seeds->each(function ($file) use ($filesystem) {
$path = database_path('seeders').'/'.$file->getFilename();
$stub = str_replace(
["<?php\n\nuse", "<?php".PHP_EOL.PHP_EOL."use"],
"<?php".PHP_EOL.PHP_EOL."namespace Database\\Seeders;".PHP_EOL.PHP_EOL."use",
$filesystem->get($path)
);

$filesystem->put($path, $stub);
});
}
}
Loading

0 comments on commit 19286d1

Please sign in to comment.