Skip to content

Commit

Permalink
Laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
henzeb committed Mar 11, 2024
1 parent f106694 commit 4064111
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [ '8.0','8.1','8.2' ]
php: [ '8.1','8.2', '8.3' ]
stability: [ prefer-lowest, prefer-stable ]

steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.php_cs
.php_cs.cache
.phpunit.result.cache
.phpunit.cache/
build
composer.lock
coverage
Expand Down
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
"ext-pcntl": "*"
},
"require": {
"php": "^8.0",
"illuminate/support": "^9.0|^10"
"php": "^8.1",
"illuminate/support": "^10|^11"
},
"require-dev": {
"infection/infection": "^0.26.19",
"nesbot/carbon": "v2.64.0",
"orchestra/testbench": "^v7.0.0|8.0",
"nesbot/carbon": "v2.72.2",
"orchestra/testbench": "^v8.21.1|^9",
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9.6.6"
"phpunit/phpunit": "^9.6.6|^10"
},
"autoload": {
"files": [
Expand Down
48 changes: 22 additions & 26 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<!-- <server name="DB_CONNECTION" value="sqlite"/> -->
<!-- <server name="DB_DATABASE" value=":memory:"/> -->
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<!-- <server name="DB_CONNECTION" value="sqlite"/> -->
<!-- <server name="DB_DATABASE" value=":memory:"/> -->
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Output/BufferedOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function getStream()
return $this->stream ??= fopen('php://memory', 'r+');
}

protected function doWrite(string $message, bool $newline)
protected function doWrite(string $message, bool $newline): void
{
fwrite($this->getStream(), $message . ($newline ? PHP_EOL : ''));
fflush($this->getStream());
Expand Down
6 changes: 3 additions & 3 deletions src/Output/ConsoleSectionOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function () {
);
}

public function setVerbosity(int $level)
public function setVerbosity(int $level): void
{
parent::setVerbosity($level);
}
Expand Down Expand Up @@ -166,7 +166,7 @@ public function render(callable $message)
$this->replace($streamer->getContent());
}

public function clear(int $lines = null)
public function clear(int $lines = null): void
{
if ($lines === null) {
$this->write("\033[0m");
Expand All @@ -184,6 +184,6 @@ public function delete(int $lines = null): self

public function newLine($count = 1)
{
$this->write(str_repeat(PHP_EOL, $count - 1));
$this->write(str_repeat(PHP_EOL, $count - 1), true);
}
}
2 changes: 1 addition & 1 deletion src/Output/TailConsoleSectionOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function tail(int $maxHeight = 10): TailConsoleSectionOutput
return $this;
}

protected function doWrite(string $message, bool $newline)
protected function doWrite(string $message, bool $newline): void
{
if ($this->allowWriteTail && $this->contentEndsWithNewLine()) {
$this->writeTail($message, $newline);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Console/Concerns/HandlesVerbosityOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected function getPackageProviders($app)
return [ConsoleServiceProvider::class, StubCommandServiceProvider::class];
}

public function providesVerbosityCases(): array
public static function providesVerbosityCases(): array
{
return [
'verbose' => ['method' => 'verbose', 'verbosity' => ConsoleOutputInterface::VERBOSITY_VERBOSE],
Expand All @@ -28,7 +28,7 @@ public function providesVerbosityCases(): array
}


public function providesVerbosityOutputTestcases()
public static function providesVerbosityOutputTestcases()
{
return [
'debug-debug' => [
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Console/Concerns/InteractsWithExitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

class InteractsWithExitTest extends TestCase
{
protected function getPackageProviders($app)
protected function getPackageProviders($app): array
{
return [
ConsoleServiceProvider::class
];
}

public function providesMethods(): array
public static function providesMethods(): array
{
return [
'shouldExit' => ['shouldExit'],
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Console/Concerns/InteractsWithIOTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ class InteractsWithIOTest extends TestCase
{
use Conditionable;

protected function getPackageProviders($app)
protected function getPackageProviders($app): array
{
return [
ConsoleServiceProvider::class
];
}

public function providesOldVersions()
public static function providesOldVersions(): array
{
return [
'8.83.23' => ['8.83.23'],
'9.20.23' => ['9.20.23'],
];
}

public function providesNewVersions()
public static function providesNewVersions(): array
{
return [
'9.21.0' => ['9.21.0'],
Expand Down
14 changes: 8 additions & 6 deletions tests/Unit/Console/Concerns/InteractsWithInfiniteLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Henzeb\Console\Tests\Unit\Console\Concerns;

use RuntimeException;
use PHPUnit\Framework\Assert;
use Orchestra\Testbench\TestCase;
use Illuminate\Support\Facades\App;
use Henzeb\Console\Concerns\InteractsWithInfiniteLoop;
use Illuminate\Support\Facades\App;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Assert;
use RuntimeException;


class InteractsWithInfiniteLoopTest extends TestCase
Expand All @@ -29,7 +29,7 @@ public function testShouldBlockWhenNotInUnitTest()
$infiniteLoops->watchShouldLoop(1);
}

public function providesLoopCounts()
public static function providesLoopCounts(): array
{
return [
'1' => [1],
Expand All @@ -51,7 +51,9 @@ public function testShouldLoopGivenTimes(int $loops)
use InteractsWithInfiniteLoop {
infiniteLoop as public;
}
public function shouldSleepWith(int $seconds) {

public function shouldSleepWith(int $seconds)
{
Assert::assertEquals(2, $seconds);
}
};
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Console/Concerns/InteractsWithSleepTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

class InteractsWithSleepTest extends TestCase
{
protected function getPackageProviders($app)
protected function getPackageProviders($app): array
{
return [
ConsoleServiceProvider::class
];
}

public function providesMethods(): array
public static function providesMethods(): array
{
return [
'shouldSleep' => ['shouldSleep'],
Expand Down
12 changes: 7 additions & 5 deletions tests/Unit/Console/Output/ConsoleOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


use Closure;
use Henzeb\Console\Facades\Console;
use Henzeb\Console\Output\ConsoleOutput;
use Henzeb\Console\Output\ConsoleSectionOutput;
use Henzeb\Console\Output\TailConsoleSectionOutput;
Expand All @@ -17,10 +16,11 @@
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput as SymfonyConsoleOutput;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use function resolve;

class ConsoleOutputTest extends TestCase
{
protected function getPackageProviders($app)
protected function getPackageProviders($app): array
{
return [ConsoleServiceProvider::class];
}
Expand All @@ -42,9 +42,11 @@ public function testShouldSetInputWhenNewOutputIsSet(): void

public function testShouldAutomaticallySetOutputStyle()
{
Console::partialMock()->shouldReceive('setOutput')->atLeast()->twice();
$mock = $this->mock(ConsoleOutput::class)->makePartial();

$this->artisan('env');
$mock->expects('setOutput')->atLeast()->once();

resolve('henzeb.outputstyle');
}

public function testShouldHaveDefaultOutput()
Expand Down Expand Up @@ -151,7 +153,7 @@ public function testWatchDoesNotAllowNegativeRefreshRate()
$output->watch(fn() => true, -1);
}

public function providesWatchRuns()
public static function providesWatchRuns(): array
{
return [
['loops' => 2, 'sleep' => 1],
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Console/Output/ConsoleSectionOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class ConsoleSectionOutputTest extends TestCase
{
protected function getPackageProviders($app)
protected function getPackageProviders($app): array
{
return [
ConsoleServiceProvider::class
Expand All @@ -47,7 +47,7 @@ public function testShouldReturnProgressBar(): void
$outputStyle = $this->mock(OutputStyle::class);
$outputStyle->expects('isDecorated')->andReturn(true);
$outputStyle->expects('getVerbosity')->andReturn(true);
$outputStyle->expects('getFormatter')->times(4)->andReturn(new OutputFormatter());
$outputStyle->expects('getFormatter')->atLeast()->times(3)->andReturn(new OutputFormatter());
$outputStyle->expects('createProgressBar')->andReturns(new ProgressBar($outputStyle));

$outputStyle->expects('write')->times(4);
Expand Down Expand Up @@ -203,7 +203,7 @@ public function testReplaceUsesWriteMethodTwiceWithArray(): void
$output->replace(['test', 'test2']);
}

public function providesVerbosityLevels(): array
public static function providesVerbosityLevels(): array
{
return [
[OutputInterface::VERBOSITY_DEBUG],
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Console/Output/TailConsoleSectionOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function getPackageProviders($app)
];
}

public function providesConstructTestcases(): array
public static function providesConstructTestcases(): array
{
return [
[1, true, 10],
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Console/Providers/ConsoleServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function () use ($unit) {
Artisan::call('myApplication');
}

public function providesFormatterStyleTestCases(): array
public static function providesFormatterStyleTestCases(): array
{
return [
['henzeb.console.verbose', "\e[36mtest\e[39m"],
Expand All @@ -73,7 +73,7 @@ public function testShouldHaveStyleRegistered(
$this->assertEquals($expected, $formatter->format(sprintf('<%s>test</>', $tag)));
}

public function providesOutputStyleResolveCases(): array
public static function providesOutputStyleResolveCases(): array
{
return [
[
Expand Down

0 comments on commit 4064111

Please sign in to comment.