Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@master
- uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.4'
tools: composer
- name: Install dependencies
run: composer update -n --prefer-dist
Expand All @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.0', '8.1']
php-versions: ['8.4', '8.5']
prefer-lowest: ['', '--prefer-lowest']
steps:
- uses: actions/checkout@master
Expand All @@ -30,23 +30,23 @@ jobs:
coverage: pcov
tools: composer
- name: Install dependencies
if: matrix.php-versions != '8.1'
run: composer update -n --prefer-dist ${{ matrix.prefer-lowest }}
- name: Install dependencies
if: matrix.php-versions == '8.1'
run: composer install -n --prefer-dist --ignore-platform-req=php
- name: Run PHPUnit unit tests
run: vendor/bin/phpunit --coverage-clover=build/logs/clover.xml
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
if: matrix.php-versions == '8.0'
if: matrix.php-versions == '8.4'

run:
name: Run current version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: composer
- name: Install dependencies
run: composer install -n --prefer-dist
- name: Add a very basic htaccess file
Expand Down
4 changes: 2 additions & 2 deletions bin/htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ foreach ($potentialAutoloadLocations as $file) {
use Http\Adapter\Guzzle7\Client;
use Http\Factory\Guzzle\ServerRequestFactory;
use Madewithlove\Htaccess\TableRenderer;
use Madewithlove\HtaccessClient;
use Madewithlove\HtaccessApiClient\HtaccessClient;
use Madewithlove\HtaccessCommand;
use Symfony\Component\Console\Application;

Expand All @@ -32,7 +32,7 @@ $htaccessClient = new HtaccessClient(
);

$htaccessCommand = new HtaccessCommand($htaccessClient, new TableRenderer());
$application->add($htaccessCommand);
$application->addCommand($htaccessCommand);
$application->setDefaultCommand($htaccessCommand->getName(), true);

$application->run();
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"description": "CLI interface for the best htaccess tester in the world.",
"type": "package",
"require": {
"php": "^8.0",
"symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"php": "^8.4",
"symfony/console": "^7.0 || ^8.0",
"http-interop/http-factory-guzzle": "^1.0",
"php-http/guzzle7-adapter": "^1.0",
"madewithlove/htaccess-api-client": "^2.3",
"symfony/yaml": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"
"madewithlove/htaccess-api-client": "^3.0",
"symfony/yaml": "^7.0 || ^8.0"
},
"bin": [
"bin/htaccess"
Expand All @@ -21,8 +21,8 @@
},
"license": "GPL-3.0-or-later",
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.0.0"
"phpunit/phpunit": "^13.0",
"phpstan/phpstan": "^2.0"
},
"config": {
"allow-plugins": {
Expand Down
8 changes: 4 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<testsuite name="Tests">
<directory>tests</directory>
</testsuite>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<source>
<include>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</include>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/Htaccess/TableRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Madewithlove\Htaccess;

use Madewithlove\HtaccessResult;
use Madewithlove\ResultLine;
use Madewithlove\HtaccessApiClient\HtaccessResult;
use Madewithlove\HtaccessApiClient\ResultLine;
use Symfony\Component\Console\Style\SymfonyStyle;

final class TableRenderer
Expand Down
10 changes: 7 additions & 3 deletions src/HtaccessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

use InvalidArgumentException;
use Madewithlove\Htaccess\TableRenderer;
use Madewithlove\HtaccessApiClient\HtaccessClient;
use Madewithlove\HtaccessApiClient\HtaccessException;
use Madewithlove\HtaccessApiClient\HtaccessResult;
use Madewithlove\HtaccessApiClient\ServerVariables;
use RuntimeException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\RuntimeException as SymfonyRuntimeException;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -14,15 +19,14 @@
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Yaml\Yaml;

#[AsCommand(name: 'htaccess')]
final class HtaccessCommand extends Command
{
protected static $defaultName = 'htaccess';

public function __construct(
private HtaccessClient $htaccessClient,
private TableRenderer $tableRenderer
) {
parent::__construct(self::$defaultName);
parent::__construct();
}

protected function configure(): void
Expand Down
24 changes: 13 additions & 11 deletions tests/HtaccessCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Http\Adapter\Guzzle7\Client;
use Http\Factory\Guzzle\ServerRequestFactory;
use Madewithlove\Htaccess\TableRenderer;
use Madewithlove\HtaccessApiClient\HtaccessClient;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Tester\CommandTester;
Expand Down Expand Up @@ -35,7 +37,7 @@ public function tearDown(): void
@unlink(getcwd() . '/tests/.htaccess');
}

/** @test */
#[Test]
public function it does not run without url argument(): void
{
$commandTester = new CommandTester($this->command);
Expand All @@ -45,7 +47,7 @@ public function it does not run without url argument(): void
$commandTester->execute([]);
}

/** @test */
#[Test]
public function it does not run without htaccess file available(): void
{
$commandTester = new CommandTester($this->command);
Expand All @@ -57,7 +59,7 @@ public function it does not run without htaccess file available(): void
]);
}

/** @test */
#[Test]
public function it does run(): void
{
file_put_contents(
Expand Down Expand Up @@ -87,7 +89,7 @@ public function it does run(): void
);
}

/** @test */
#[Test]
public function it has exit status zero when expected url is correct(): void
{
file_put_contents(
Expand All @@ -104,7 +106,7 @@ public function it has exit status zero when expected url is correct():
$this->assertEquals(0, $commandTester->getStatusCode());
}

/** @test */
#[Test]
public function it has exit status one when expected url is incorrect(): void
{
file_put_contents(
Expand All @@ -121,7 +123,7 @@ public function it has exit status one when expected url is incorrect()
$this->assertEquals(1, $commandTester->getStatusCode());
}

/** @test */
#[Test]
public function it is possible to share a test run(): void
{
file_put_contents(
Expand All @@ -141,7 +143,7 @@ public function it is possible to share a test run(): void
);
}

/** @test */
#[Test]
public function it can specify a custom path to the htaccess file(): void
{
file_put_contents(
Expand All @@ -161,7 +163,7 @@ public function it can specify a custom path to the htaccess file(): vo
);
}

/** @test */
#[Test]
public function it does mark an unsupported line as potentially invalid(): void
{
file_put_contents(
Expand All @@ -181,7 +183,7 @@ public function it does mark an unsupported line as potentially invalid(
);
}

/** @test */
#[Test]
public function it supports http referrer(): void
{
file_put_contents(
Expand All @@ -201,7 +203,7 @@ public function it supports http referrer(): void
);
}

/** @test */
#[Test]
public function it supports server name(): void
{
file_put_contents(
Expand All @@ -221,7 +223,7 @@ public function it supports server name(): void
);
}

/** @test */
#[Test]
public function it supports http user agent(): void
{
file_put_contents(
Expand Down
12 changes: 7 additions & 5 deletions tests/MultipleUrlsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Http\Adapter\Guzzle7\Client;
use Http\Factory\Guzzle\ServerRequestFactory;
use Madewithlove\Htaccess\TableRenderer;
use Madewithlove\HtaccessApiClient\HtaccessClient;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Tester\CommandTester;
Expand Down Expand Up @@ -43,7 +45,7 @@ public function tearDown(): void
@unlink(getcwd() . '/test-urls.yaml');
}

/** @test */
#[Test]
public function it does work if the passed url list is not available(): void
{
$commandTester = new CommandTester($this->command);
Expand All @@ -55,7 +57,7 @@ public function it does work if the passed url list is not available()
]);
}

/** @test */
#[Test]
public function it throws when passing both a url and a url list(): void
{
$commandTester = new CommandTester($this->command);
Expand All @@ -68,7 +70,7 @@ public function it throws when passing both a url and a url list(): vo
]);
}

/** @test */
#[Test]
public function it does run with multiple urls(): void
{
file_put_contents(
Expand Down Expand Up @@ -99,7 +101,7 @@ public function it does run with multiple urls(): void
$this->assertEquals(0, $commandTester->getStatusCode());
}

/** @test */
#[Test]
public function it renders status code with multiple urls(): void
{
file_put_contents(
Expand All @@ -126,7 +128,7 @@ public function it renders status code with multiple urls(): void
$this->assertEquals(0, $commandTester->getStatusCode());
}

/** @test */
#[Test]
public function it has exit status one when at least one expected url is incorrect(): void
{
file_put_contents(
Expand Down
Loading