Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace setMethods with addMethods #252

Merged
merged 4 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 0 additions & 14 deletions tests/BodyTest.php
Expand Up @@ -71,8 +71,6 @@ public function testConstructorAttachesStream()
$this->assertSame($this->stream, $bodyStream->getValue($body));
}

/**
*/
public function testConstructorInvalidStream()
{
$this->expectException(InvalidArgumentException::class);
Expand Down Expand Up @@ -204,8 +202,6 @@ public function testTellAttached()
$this->assertEquals(10, $body->tell());
}

/**
*/
public function testTellDetachedThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand Down Expand Up @@ -330,8 +326,6 @@ public function testSeekAttached()
$this->assertEquals(10, ftell($this->stream));
}

/**
*/
public function testSeekDetachedThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand All @@ -353,8 +347,6 @@ public function testRewindAttached()
$this->assertEquals(0, ftell($this->stream));
}

/**
*/
public function testRewindDetachedThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand All @@ -374,8 +366,6 @@ public function testReadAttached()
$this->assertEquals(substr($this->text, 0, 10), $body->read(10));
}

/**
*/
public function testReadDetachedThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand All @@ -399,8 +389,6 @@ public function testWriteAttached()
$this->assertEquals($this->text . 'foo', (string) $body);
}

/**
*/
public function testWriteDetachedThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand All @@ -421,8 +409,6 @@ public function testGetContentsAttached()
$this->assertEquals(substr($this->text, 10), $body->getContents());
}

/**
*/
public function testGetContentsDetachedThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand Down
2 changes: 0 additions & 2 deletions tests/CookiesTest.php
Expand Up @@ -267,8 +267,6 @@ public function testToHeader()
$this->assertEquals('test_date=Works; expires=' . $formattedStringDate, $cookieStringDate);
}

/**
*/
public function testParseHeaderException()
{
$this->expectException(InvalidArgumentException::class);
Expand Down
2 changes: 0 additions & 2 deletions tests/Factory/RequestFactoryTest.php
Expand Up @@ -36,8 +36,6 @@ protected function createUri($uri)
return (new UriFactory())->createUri($uri);
}

/**
*/
public function testCreateRequestThrowsExceptionWithInvalidUri()
{
$this->expectException(InvalidArgumentException::class);
Expand Down
4 changes: 0 additions & 4 deletions tests/Factory/ServerRequestFactoryTest.php
Expand Up @@ -197,8 +197,6 @@ public function testCreateFromGlobalsParsesBodyWithFragmentedContentType()
$this->assertEquals($_POST, $request->getParsedBody());
}

/**
*/
public function testCreateServerRequestWithNullAsUri()
{
$this->expectException(InvalidArgumentException::class);
Expand All @@ -207,8 +205,6 @@ public function testCreateServerRequestWithNullAsUri()
$this->createServerRequestFactory()->createServerRequest('GET', null, $env);
}

/**
*/
public function testCreateServerRequestWithInvalidUriObject()
{
$this->expectException(InvalidArgumentException::class);
Expand Down
6 changes: 0 additions & 6 deletions tests/Factory/StreamFactoryTest.php
Expand Up @@ -32,8 +32,6 @@ protected function createStreamFactory()
return new StreamFactory();
}

/**
*/
public function testCreateStreamThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand All @@ -46,8 +44,6 @@ public function testCreateStreamThrowsRuntimeException()
$factory->createStream();
}

/**
*/
public function testCreateStreamFromFileThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand All @@ -61,8 +57,6 @@ public function testCreateStreamFromFileThrowsRuntimeException()
$factory->createStreamFromFile('non-readable');
}

/**
*/
public function testCreateStreamFromResourceThrowsRuntimeException()
{
$this->expectException(InvalidArgumentException::class);
Expand Down
4 changes: 0 additions & 4 deletions tests/Factory/UploadedFileFactoryTest.php
Expand Up @@ -72,8 +72,6 @@ protected function prophesizeStreamInterfaceWithGetMetadataMethod(string $argKey
return $stream;
}

/**
*/
public function testCreateUploadedFileWithInvalidUri()
{
$this->expectException(InvalidArgumentException::class);
Expand All @@ -94,8 +92,6 @@ public function testCreateUploadedFileWithInvalidUri()
$this->factory->createUploadedFile($stream);
}

/**
*/
public function testCreateUploadedFileWithNonReadableFile()
{
$this->expectException(InvalidArgumentException::class);
Expand Down
2 changes: 0 additions & 2 deletions tests/HeaderTest.php
Expand Up @@ -60,8 +60,6 @@ public function testAddValuesString()
$this->assertSame($header2, $header);
}

/**
*/
public function testAddValuesNull()
{
$this->expectException(InvalidArgumentException::class);
Expand Down
4 changes: 0 additions & 4 deletions tests/HeadersTest.php
Expand Up @@ -57,8 +57,6 @@ public function testAddHeader()
$this->assertEquals(['Accept' => ['application/json', 'text/html']], $headers->getHeaders(true));
}

/**
*/
public function testAddHeaderValueEmptyArray()
{
$this->expectException(InvalidArgumentException::class);
Expand Down Expand Up @@ -106,8 +104,6 @@ public function testGetHeaderReturnsValidatedAndTrimedHeaderDefaultValue()
$this->assertEquals(['application/json'], $headers->getHeader('accept', ' application/json'));
}

/**
*/
public function testGetHeaderThrowsExceptionWithInvalidDefaultArgument()
{
$this->expectException(InvalidArgumentException::class);
Expand Down
2 changes: 0 additions & 2 deletions tests/MessageTest.php
Expand Up @@ -35,8 +35,6 @@ public function testWithProtocolVersion()
$this->assertEquals('1.0', $clone->protocolVersion);
}

/**
*/
public function testWithProtocolVersionInvalidThrowsException()
{
$this->expectException(InvalidArgumentException::class);
Expand Down
8 changes: 0 additions & 8 deletions tests/NonBufferedBodyTest.php
Expand Up @@ -125,8 +125,6 @@ public function testWithoutHeader()
self::assertSame([], HeaderStack::stack());
}

/**
*/
public function testCloseThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand All @@ -135,8 +133,6 @@ public function testCloseThrowsRuntimeException()
(new NonBufferedBody())->close();
}

/**
*/
public function testSeekThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand All @@ -145,8 +141,6 @@ public function testSeekThrowsRuntimeException()
(new NonBufferedBody())->seek(10);
}

/**
*/
public function testRewindThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand All @@ -155,8 +149,6 @@ public function testRewindThrowsRuntimeException()
(new NonBufferedBody())->rewind();
}

/**
*/
public function testReadThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand Down
12 changes: 0 additions & 12 deletions tests/RequestTest.php
Expand Up @@ -84,17 +84,13 @@ public function testWithAllAllowedCharactersMethod()
$this->assertEquals("!#$%&'*+.^_`|~09AZ-", $request->getMethod());
}

/**
*/
public function testWithMethodInvalid()
{
$this->expectException(InvalidArgumentException::class);

$this->requestFactory()->withMethod('B@R');
}

/**
*/
public function testCreateRequestWithInvalidMethodString()
{
$this->expectException(InvalidArgumentException::class);
Expand All @@ -108,8 +104,6 @@ public function testCreateRequestWithInvalidMethodString()
new Request('B@R', $uri, $headers, $cookies, $serverParams, $body);
}

/**
*/
public function testCreateRequestWithInvalidMethodOther()
{
$this->expectException(InvalidArgumentException::class);
Expand Down Expand Up @@ -155,8 +149,6 @@ public function testWithRequestTarget()
$this->assertEquals('/test?user=1', $clone->getRequestTarget());
}

/**
*/
public function testWithRequestTargetThatHasSpaces()
{
$this->expectException(InvalidArgumentException::class);
Expand Down Expand Up @@ -450,17 +442,13 @@ public function testGetParsedBodyReturnsNullWhenThereIsNoMediaTypeParserRegister
$this->assertNull($request->getParsedBody());
}

/**
*/
public function testWithParsedBodyInvalid()
{
$this->expectException(InvalidArgumentException::class);

$this->requestFactory()->withParsedBody(2);
}

/**
*/
public function testWithParsedBodyInvalidFalseValue()
{
$this->expectException(InvalidArgumentException::class);
Expand Down
6 changes: 1 addition & 5 deletions tests/ResponseTest.php
Expand Up @@ -96,8 +96,6 @@ public function testWithStatus()
$this->assertEquals(302, $clone->getStatusCode());
}

/**
*/
public function testWithStatusInvalidStatusCodeThrowsException()
{
$this->expectException(InvalidArgumentException::class);
Expand All @@ -106,8 +104,6 @@ public function testWithStatusInvalidStatusCodeThrowsException()
$response->withStatus(800);
}

/**
*/
public function testWithStatusInvalidReasonPhraseThrowsException()
{
$this->expectException(InvalidArgumentException::class);
Expand Down Expand Up @@ -144,7 +140,7 @@ public function testResonPhraseContainsLineFeed()

public function testWithStatusValidReasonPhraseObject()
{
$mock = $this->getMockBuilder('ResponseTestReasonPhrase')->setMethods(['__toString'])->getMock();
$mock = $this->getMockBuilder(\stdClass::class)->addMethods(['__toString'])->getMock();
nbayramberdiyev marked this conversation as resolved.
Show resolved Hide resolved
$mock->expects($this->once())
->method('__toString')
->will($this->returnValue('Slim OK'));
Expand Down
6 changes: 0 additions & 6 deletions tests/StreamTest.php
Expand Up @@ -73,8 +73,6 @@ public function testPipeIsNotSeekable()
$this->assertFalse($this->pipeStream->isSeekable());
}

/**
*/
public function testCannotSeekPipe()
{
$this->expectException(RuntimeException::class);
Expand All @@ -84,8 +82,6 @@ public function testCannotSeekPipe()
$this->pipeStream->seek(0);
}

/**
*/
public function testCannotTellPipe()
{
$this->expectException(RuntimeException::class);
Expand All @@ -95,8 +91,6 @@ public function testCannotTellPipe()
$this->pipeStream->tell();
}

/**
*/
public function testCannotRewindPipe()
{
$this->expectException(RuntimeException::class);
Expand Down
8 changes: 0 additions & 8 deletions tests/UploadedFileTest.php
Expand Up @@ -245,8 +245,6 @@ public function testMoveTo(UploadedFile $uploadedFile)
return $uploadedFile;
}

/**
*/
public function testMoveToRenameFailure()
{
$this->expectException(RuntimeException::class);
Expand Down Expand Up @@ -367,8 +365,6 @@ public function testMoveToStream()
}
}

/**
*/
public function testMoveToStreamCopyFailure()
{
$this->expectException(RuntimeException::class);
Expand Down Expand Up @@ -423,17 +419,13 @@ private function runFileUploadWithTempStreamTest(callable $streamFactory, callab
$this->assertSame($stream->getMetadata('uri'), $file->getFilePath());
}

/**
*/
public function testCreateUploadedFileWithInvalidArguments()
{
$this->expectException(InvalidArgumentException::class);

new UploadedFile(42); // a random value that is neither a string nor an instance of StreamInterface
}

/**
*/
public function testCreateUploadedFileWithInvalidUri()
{
$this->expectException(InvalidArgumentException::class);
Expand Down