summaryrefslogtreecommitdiffstats
path: root/tests/support/TestHelper.php
blob: 8f4d2f90d148adae7698d6ffd676b4b4b1100f56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

namespace Jasny\Controller;

use Jasny\Controller;

/**
 * Additional test methods
 */
trait TestHelper
{
    /**
     * Get the controller class
     * 
     * @return string
     */
    protected function getControllerClass()
    {
        return Controller::class;
    }
    
    /**
     * Get mock for controller
     *
     * @param array $methods  Methods to mock
     * @return Controller|\PHPUnit_Framework_MockObject_MockObject
     */
    public function getController($methods = [])
    {
        $builder = $this->getMockBuilder($this->getControllerClass())->disableOriginalConstructor();
        if ($methods) {
            $builder->setMethods($methods);
        }

        return $builder->getMockForAbstractClass();
    }
}