Completed
Push — master ( e46808...b698dc )
by Julián
02:11
created

tests/Pusher/Controller/AbstractControllerTest.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Push notification server example (http://github.com/juliangut/tify_example)
4
 *
5
 * @link https://github.com/juliangut/tify_example for the canonical source repository
6
 *
7
 * @license https://github.com/juliangut/tify_example/blob/master/LICENSE
8
 */
9
10
namespace Jgut\Pusher\Tests\Entity;
11
12
use Jgut\Pusher\Controller\AbstractController;
13
use Psr\Http\Message\ServerRequestInterface;
14
15
/**
16
 * Class AbstractControllerTest
17
 */
18
class AbstractControllerTest extends \PHPUnit_Framework_TestCase
19
{
20
    /**
21
     * @var AbstractController
22
     */
23
    protected $controller;
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function setUp()
29
    {
30
        $this->controller = $this->getMockForAbstractClass(AbstractController::class);
31
    }
32
33
    public function testParameters()
34
    {
35
        $reflection = new \ReflectionClass(get_class($this->controller));
36
        $method = $reflection->getMethod('resolveRequestParameters');
37
        $method->setAccessible(true);
38
39
        $parameters = [
40
            'param1' => 'value1',
41
        ];
42
43
        $request = $this->getMock(ServerRequestInterface::class, [], [], '', false);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
44
        $request->expects(self::once())->method('getParsedBody')->will(self::returnValue($parameters));
45
46
        self::assertEquals($parameters, $method->invokeArgs($this->controller, [$request, ['param1'], [], ['param1']]));
47
    }
48
49
    /**
50
     * @expectedException \RuntimeException
51
     */
52
    public function testBadParameters()
53
    {
54
        $reflection = new \ReflectionClass(get_class($this->controller));
55
        $method = $reflection->getMethod('resolveRequestParameters');
56
        $method->setAccessible(true);
57
58
        $request = $this->getMock(ServerRequestInterface::class, [], [], '', false);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
59
        $request->expects(self::once())->method('getParsedBody')->will(self::returnValue([]));
60
61
        $method->invokeArgs($this->controller, [$request, ['param1'], [], ['param1']]);
62
    }
63
}
64