Skip to content

Commit

Permalink
use os 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptouuuu committed Nov 1, 2023
1 parent 00b0aee commit 12d4792
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 49 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.1', '8.2', '8.3']
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
name: 'PHPUnit'
steps:
Expand All @@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1', '8.2', '8.3']
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
name: 'Psalm'
steps:
Expand All @@ -54,7 +54,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1']
php-version: ['8.2']
name: 'CS'
steps:
- name: Checkout
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,15 @@
# Changelog

## [Unreleased]

### Changed

- Requires `innmind/operating-system:~4.0`

### Removed

- Support for PHP `8.1`

## 6.1.0 - 2023-09-23

### Added
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -23,10 +23,10 @@
}
},
"require": {
"php": "~8.1",
"php": "~8.2",
"innmind/url": "~4.1",
"innmind/immutable": "~4.13|~5.0",
"innmind/http-transport": "~6.5"
"innmind/http-transport": "~7.0"
},
"require-dev": {
"phpunit/phpunit": "~9.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Directives.php
Expand Up @@ -152,7 +152,7 @@ public function asContent(): Content
),
);

return Content\Lines::of($lines);
return Content::ofLines($lines);
}

private function allows(string $url): bool
Expand Down
6 changes: 3 additions & 3 deletions src/Parser.php
Expand Up @@ -7,8 +7,8 @@
use Innmind\HttpTransport\Transport;
use Innmind\Url\Url;
use Innmind\Http\{
Message\Request\Request,
Message\Method,
Request,
Method,
ProtocolVersion,
Headers,
Header,
Expand Down Expand Up @@ -37,7 +37,7 @@ private function __construct(
public function __invoke(Url $url): Maybe
{
return ($this->fulfill)(
new Request(
Request::of(
$url,
Method::get,
ProtocolVersion::v20,
Expand Down
2 changes: 1 addition & 1 deletion src/RobotsTxt.php
Expand Up @@ -64,7 +64,7 @@ public function disallows(string $userAgent, Url $url): bool

public function asContent(): Content
{
return Content\Lines::of(
return Content::ofLines(
$this
->directives
->map(static fn($directive) => $directive->asContent())
Expand Down
2 changes: 1 addition & 1 deletion src/UserAgent.php
Expand Up @@ -58,7 +58,7 @@ public function matches(string $userAgent): bool

public function asContent(): Content
{
return Content\Lines::of(
return Content::ofLines(
$this
->agents
->map(static fn($agent) => $agent->prepend('User-agent: '))
Expand Down
67 changes: 29 additions & 38 deletions tests/ParserTest.php
Expand Up @@ -15,10 +15,11 @@
};
use Innmind\Filesystem\File\Content;
use Innmind\Url\Url;
use Innmind\Http\Message\{
use Innmind\Http\{
Request,
StatusCode,
Response,
Response\StatusCode,
ProtocolVersion,
};
use Innmind\Immutable\Either;
use PHPUnit\Framework\TestCase;
Expand All @@ -32,31 +33,25 @@ public function testExecution()
'InnmindCrawler',
);
$url = Url::of('http://example.com');
$response = $this->createMock(Response::class);
$response
->expects($this->once())
->method('statusCode')
->willReturn(StatusCode::ok);
$response
->expects($this->once())
->method('body')
->willReturn(
Content\Lines::ofContent(<<<TXT
Sitemap : foo.xml
Host : example.com
Crawl-delay: 10
User-agent : Foo
User-agent : Bar
Allow : /foo
Disallow : /bar
$response = Response::of(
StatusCode::ok,
ProtocolVersion::v11,
null,
Content::ofString(<<<TXT
Sitemap : foo.xml
Host : example.com
Crawl-delay: 10
User-agent : Foo
User-agent : Bar
Allow : /foo
Disallow : /bar
User-agent : *
Disallow :
Crawl-delay : 10
Crawl-delay : 20
TXT
),
);
User-agent : *
Disallow :
Crawl-delay : 10
Crawl-delay : 20
TXT),
);
$transport
->expects($this->once())
->method('__invoke')
Expand All @@ -71,8 +66,8 @@ public function testExecution()
) &&
$request->body()->toString() === '';
}))
->willReturn(Either::right(new Success(
$this->createMock(Request::class),
->willReturnCallback(static fn($request) => Either::right(new Success(
$request,
$response,
)));
$expected = 'User-agent: Foo'."\n";
Expand Down Expand Up @@ -101,19 +96,15 @@ public function testThrowWhenRequestNotFulfilled()
'InnmindCrawler',
);
$url = Url::of('http://example.com');
$response = $this->createMock(Response::class);
$response
->expects($this->once())
->method('statusCode')
->willReturn(StatusCode::notFound);
$response
->expects($this->never())
->method('body');
$response = Response::of(
StatusCode::notFound,
ProtocolVersion::v11,
);
$transport
->expects($this->once())
->method('__invoke')
->willReturn(Either::left(new ClientError(
$this->createMock(Request::class),
->willReturnCallback(static fn($request) => Either::left(new ClientError(
$request,
$response,
)));

Expand Down

0 comments on commit 12d4792

Please sign in to comment.