Skip to content

Commit

Permalink
Fix tests due yiisoft/data-response changes (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
devanych committed Jun 23, 2021
1 parent b55e53f commit c093fae
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 31 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -29,7 +29,7 @@
"yiisoft/view": "^3.0@dev"
},
"require-dev": {
"nyholm/psr7": "^1.4",
"httpsoft/http-message": "^1.0",
"phpunit/phpunit": "^9.5",
"roave/infection-static-analysis-plugin": "^1.8",
"spatie/phpunit-watcher": "^1.23",
Expand Down
8 changes: 3 additions & 5 deletions tests/CsrfViewInjectionTest.php
Expand Up @@ -10,7 +10,7 @@

final class CsrfViewInjectionTest extends TestCase
{
public function testGetContentPatameters(): void
public function testGetContentParameters(): void
{
$token = '123';

Expand All @@ -21,7 +21,7 @@ public function testGetContentPatameters(): void
$this->assertSame($token, current($parameters));
}

public function testGetLayoutPatameters(): void
public function testGetLayoutParameters(): void
{
$token = '123';

Expand Down Expand Up @@ -84,8 +84,6 @@ public function testImmutability(): void

private function getInjection(string $token = null): CsrfViewInjection
{
return new CsrfViewInjection(
new FakeCsrfToken($token)
);
return new CsrfViewInjection(new FakeCsrfToken($token));
}
}
2 changes: 1 addition & 1 deletion tests/Exception/InvalidLinkTagExceptionTest.php
Expand Up @@ -19,7 +19,7 @@ public function testBase(): void
$this->assertSame('Invalid link tag configuration in injection', $exception->getName());
$this->assertStringStartsWithIgnoringLineEndings(
"Got link tag:\narray (\n)\n\nIn injection that implements",
$exception->getSolution()
$exception->getSolution(),
);
}
}
2 changes: 1 addition & 1 deletion tests/Exception/InvalidMetaTagExceptionTest.php
Expand Up @@ -19,7 +19,7 @@ public function testBase(): void
$this->assertSame('Invalid meta tag configuration in injection', $exception->getName());
$this->assertStringStartsWithIgnoringLineEndings(
"Got meta tag:\narray (\n)\n\nIn injection that implements",
$exception->getSolution()
$exception->getSolution(),
);
}
}
33 changes: 10 additions & 23 deletions tests/ViewRendererTest.php
Expand Up @@ -4,7 +4,8 @@

namespace Yiisoft\Yii\View\Tests;

use Nyholm\Psr7\Factory\Psr17Factory;
use HttpSoft\Message\ResponseFactory;
use HttpSoft\Message\StreamFactory;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use stdClass;
Expand Down Expand Up @@ -61,10 +62,7 @@ public function testRenderWithFullPathLayout(): void
'name' => 'donatello',
]);

$this->assertSame(
'<html><body><b>donatello</b></body></html>',
(string)$response->getBody()
);
$this->assertSame('<html><body><b>donatello</b></body></html>', (string) $response->getBody());
}

public function testRenderWithoutLayout(): void
Expand All @@ -75,10 +73,7 @@ public function testRenderWithoutLayout(): void
'name' => 'donatello',
]);

$this->assertSame(
'<b>donatello</b>',
(string)$response->getBody()
);
$this->assertSame('<b>donatello</b>', (string) $response->getBody());
}

public function testRenderPartial(): void
Expand All @@ -89,10 +84,7 @@ public function testRenderPartial(): void
'name' => 'donatello',
]);

$this->assertSame(
'<b>donatello</b>',
(string)$response->getBody()
);
$this->assertSame('<b>donatello</b>', (string) $response->getBody());
}

public function testWithController(): void
Expand Down Expand Up @@ -136,7 +128,7 @@ public function testInvalidMetaTag(): void

$this->expectException(InvalidMetaTagException::class);
$this->expectExceptionMessage(
'Meta tag in injection should be instance of Yiisoft\Html\Tag\Meta or an array. Got string.'
'Meta tag in injection should be instance of Yiisoft\Html\Tag\Meta or an array. Got string.',
);
$response->getBody();
}
Expand All @@ -150,7 +142,7 @@ public function testInvalidLinkTag(): void

$this->expectException(InvalidLinkTagException::class);
$this->expectExceptionMessage(
'Link tag in injection should be instance of Yiisoft\Html\Tag\Link or an array. Got string.'
'Link tag in injection should be instance of Yiisoft\Html\Tag\Link or an array. Got string.',
);
$response->getBody();
}
Expand All @@ -164,7 +156,7 @@ public function testInvalidPositionInLinkTag(): void

$this->expectException(InvalidLinkTagException::class);
$this->expectExceptionMessage(
'Link tag position in injection should be integer. Got string.'
'Link tag position in injection should be integer. Got string.',
);
$response->getBody();
}
Expand All @@ -184,14 +176,9 @@ public function testImmutability(): void
private function getRenderer(): ViewRenderer
{
return new ViewRenderer(
new DataResponseFactory(
new Psr17Factory()
),
new DataResponseFactory(new ResponseFactory(), new StreamFactory()),
new Aliases(['@views' => $this->getViewsDir()]),
new WebView(
'@views',
new SimpleEventDispatcher()
),
new WebView('@views', new SimpleEventDispatcher()),
'@views',
'@views/layout'
);
Expand Down

0 comments on commit c093fae

Please sign in to comment.