1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016-2020 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\MW\View\Helper\Response; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class SlimTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $object; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
protected function setUp() : void |
18
|
|
|
{ |
19
|
|
|
if( !class_exists( '\Slim\Http\Stream' ) ) { |
20
|
|
|
$this->markTestSkipped( '\Slim\Http\Stream is not available' ); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
$response = $this->getMockBuilder( \Psr\Http\Message\ResponseInterface::class )->getMock(); |
24
|
|
|
|
25
|
|
|
$view = new \Aimeos\MW\View\Standard(); |
26
|
|
|
$this->object = new \Aimeos\MW\View\Helper\Response\Slim( $view, $response ); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
protected function tearDown() : void |
31
|
|
|
{ |
32
|
|
|
unset( $this->object ); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
public function testTransform() |
37
|
|
|
{ |
38
|
|
|
$this->assertInstanceOf( \Aimeos\MW\View\Helper\Response\Slim::class, $this->object->transform() ); |
39
|
|
|
$this->assertInstanceOf( \Psr\Http\Message\ResponseInterface::class, $this->object->transform() ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function testCreateStream() |
44
|
|
|
{ |
45
|
|
|
$stream = $this->object->createStream( fopen( __FILE__, 'r' ) ); |
46
|
|
|
|
47
|
|
|
$this->assertInstanceOf( \Slim\Http\Stream::class, $stream ); |
48
|
|
|
$this->assertInstanceOf( \Psr\Http\Message\StreamInterface::class, $stream ); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
public function testCreateStreamFilename() |
53
|
|
|
{ |
54
|
|
|
$this->assertInstanceOf( \Psr\Http\Message\StreamInterface::class, $this->object->createStream( __FILE__ ) ); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
public function testCreateStreamInvalid() |
59
|
|
|
{ |
60
|
|
|
$this->expectException( \Exception::class ); |
61
|
|
|
$this->object->createStream( -1 ); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|