Skip to content

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jan 24, 2018
1 parent d8fbe12 commit 69fa9ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [UNRELEASED]
## [1.0.0] - 2018-01-24

### Added

Expand Down Expand Up @@ -63,7 +63,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

First version

[UNRELEASED]: https://github.com/middlewares/trailing-slash/compare/v0.5.0...HEAD
[1.0.0]: https://github.com/middlewares/trailing-slash/compare/v0.5.0...v1.0.0
[0.5.0]: https://github.com/middlewares/trailing-slash/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/middlewares/trailing-slash/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/middlewares/trailing-slash/compare/v0.2.0...v0.3.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ $response = $dispatcher->dispatch(new ServerRequest());

## Options

#### `__construct(false)`
#### `__construct(booll $trailingSlash = false)`

Set `true` to add the slash instead remove so, for example, `post/23` is converted to `/post/23/`. Note that if the path contains an extension, the slash is **NOT** added. For example, `images/image.png` remains the same, instead be converted to `images/image.png/`.

Expand Down
16 changes: 5 additions & 11 deletions tests/TrailingSlashTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types = 1);

namespace Middlewares\Tests;

Expand All @@ -9,7 +10,7 @@

class TrailingSlashTest extends TestCase
{
public function removeProvider()
public function removeProvider(): array
{
return [
['/foo/bar', '/foo/bar'],
Expand All @@ -21,10 +22,8 @@ public function removeProvider()

/**
* @dataProvider removeProvider
* @param mixed $uri
* @param mixed $result
*/
public function testRemove($uri, $result)
public function testRemove(string $uri, string $result)
{
$request = Factory::createServerRequest([], 'GET', $uri);

Expand All @@ -36,11 +35,10 @@ function ($request, $next) {
},
], $request);

$this->assertInstanceOf('Psr\\Http\\Message\\ResponseInterface', $response);
$this->assertEquals($result, (string) $response->getBody());
}

public function addProvider()
public function addProvider(): array
{
return [
['/foo/bar', '/foo/bar/'],
Expand All @@ -54,10 +52,8 @@ public function addProvider()

/**
* @dataProvider addProvider
* @param mixed $uri
* @param mixed $result
*/
public function testAdd($uri, $result)
public function testAdd(string $uri, string $result)
{
$request = Factory::createServerRequest([], 'GET', $uri);

Expand All @@ -69,7 +65,6 @@ function ($request, $next) {
},
], $request);

$this->assertInstanceOf('Psr\\Http\\Message\\ResponseInterface', $response);
$this->assertEquals($result, (string) $response->getBody());
}

Expand All @@ -81,7 +76,6 @@ public function testRedirect()
(new TrailingSlash())->redirect(),
], $request);

$this->assertInstanceOf('Psr\\Http\\Message\\ResponseInterface', $response);
$this->assertEquals(301, (string) $response->getStatusCode());
$this->assertEquals('/foo/bar', $response->getHeaderLine('location'));
}
Expand Down

0 comments on commit 69fa9ff

Please sign in to comment.