Skip to content

Commit

Permalink
Merge branch '8.x'
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Apr 11, 2023
2 parents a2903ca + 21f10b1 commit 319c43f
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/.coveralls.yml export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.phpunit.cache export-ignore
/canvas.yaml export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml export-ignore
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ vendor/*

# PHPUnit
/coverage/*
/.phpunit.cache/*
/.phpunit.result.cache
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
}
},
"require": {
"php": "^8.2",
"php": ">=8.2.0 <8.3.0",
"composer-runtime-api": "^2.2",
"composer/semver": "^3.0",
"illuminate/console": "^11.0",
"illuminate/filesystem": "^11.0"
},
"require-dev": {
"laravel/pint": "^1.3",
"phpstan/phpstan": "^1.9.7",
"orchestra/testbench": "^9.0"
"laravel/pint": "^1.6",
"orchestra/testbench": "^9.0",
"phpstan/phpstan": "^1.10.6"
},
"config": {
"sort-packages": true
Expand All @@ -53,12 +55,13 @@
"post-autoload-dump": "@composer run prepare",
"prepare": "@php ./vendor/bin/testbench package:discover --ansi",
"ci": [
"@composer audit",
"@composer run prepare",
"@php vendor/bin/phpstan analyse",
"@php vendor/bin/pint",
"@composer run test"
"@php vendor/bin/pint"
],
"test": "@php vendor/bin/phpunit -c ./ --color"
},
"prefer-stable": true,
"minimum-stability": "dev"
}
42 changes: 19 additions & 23 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
verbose="true">
<coverage includeUncoveredFiles="false">
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<directory>src/Core/Commands/Concerns</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Canvas Core Test Suite">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
<php>
<ini name="memory_limit" value="256M"/>
</php>
cacheDirectory=".phpunit.cache"
backupStaticProperties="false">
<coverage includeUncoveredFiles="false">
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<directory>src/Core/Commands/Concerns</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Canvas Core Test Suite">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
<php>
<ini name="memory_limit" value="256M"/>
</php>
</phpunit>
3 changes: 3 additions & 0 deletions src/Commands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Console\Concerns\HasParameters;
use Illuminate\Console\Concerns\InteractsWithIO;
use Illuminate\Console\OutputStyle;
use Illuminate\Console\View\Components\Factory;
use Orchestra\Canvas\Core\Presets\Preset;
use Symfony\Component\Console\Command\Command as SymfonyConsole;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -45,6 +46,8 @@ public function run(InputInterface $input, OutputInterface $output): int
{
$this->output = new OutputStyle($input, $output);

$this->components = new Factory($this->output);

return parent::run(
$this->input = $input, $this->output
);
Expand Down
15 changes: 8 additions & 7 deletions src/Commands/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ protected function configure()
{
$this->ignoreValidationErrors();

$this->setName($this->name)
->setDescription($this->description)
$this->setName($this->getName())
->setDescription($this->getDescription())
->addArgument('name', InputArgument::REQUIRED, "The name of the {$this->fileType}");
}

Expand All @@ -99,19 +99,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
public function codeAlreadyExists(string $className): int
{
$this->error($this->type.' already exists!');
$this->components->error(sprintf('%s [%s] already exists!', $this->type, $className));

return 1;
return static::FAILURE;
}

/**
* Code successfully generated.
*/
public function codeHasBeenGenerated(string $className): int
{
$this->info($this->type.' created successfully.');
$this->components->info(sprintf('%s [%s] created successfully.', $this->type, $className));

return 0;
return static::SUCCESS;
}

/**
Expand All @@ -127,7 +127,8 @@ public function getPublishedStubFileName(): ?string
*/
public function generatorName(): string
{
return transform($this->argument('name'), function (string $name) {
return transform($this->argument('name'), function ($name) {
/** @var string $name */
return trim($name);
});
}
Expand Down
4 changes: 1 addition & 3 deletions src/LaravelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class LaravelServiceProvider extends ServiceProvider implements DeferrableProvid
*/
public function register(): void
{
$this->app->singleton(Presets\Preset::class, function (Container $app) {
return $this->presetForLaravel($app);
});
$this->app->singleton(Presets\Preset::class, fn (Container $app) => $this->presetForLaravel($app));
}

/**
Expand Down
11 changes: 9 additions & 2 deletions src/Testing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Orchestra\Canvas\Core\Testing;

use Composer\InstalledVersions;
use Composer\Semver\VersionParser;

class TestCase extends \Orchestra\Testbench\TestCase
{
use Concerns\InteractsWithPublishedFiles;
Expand All @@ -20,15 +23,19 @@ protected function setUp(): void
{
parent::setUp();

$this->setUpInteractsWithPublishedFiles();
if (InstalledVersions::satisfies(new VersionParser, 'orchestra/testbench-core', '<8.2.0')) {
$this->setUpInteractsWithPublishedFiles();
}
}

/**
* Teardown the test environment.
*/
protected function tearDown(): void
{
$this->tearDownInteractsWithPublishedFiles();
if (InstalledVersions::satisfies(new VersionParser, 'orchestra/testbench-core', '<8.2.0')) {
$this->tearDownInteractsWithPublishedFiles();
}

parent::tearDown();
}
Expand Down

0 comments on commit 319c43f

Please sign in to comment.