testCreationOfContactControllerViaFactory()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 19
nc 1
nop 0
1
<?php
2
3
namespace Org_Heigl\ContactTest\Service;
4
5
use Org_Heigl\Contact\Service\ContactControllerFactory;
6
use Zend\ServiceManager\ServiceManager;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * test case.
11
 */
12
class ContactControllerFactoryTest extends TestCase
13
{
14
    
15
    /**
16
     * Prepares the environment before running a test.
17
     */
18
    protected function setUp()
19
    {
20
        parent::setUp();
21
        
22
        // TODO Auto-generated ContactControllerFactoryTest::setUp()
23
    }
24
    
25
    /**
26
     * Cleans up the environment after running a test.
27
     */
28
    protected function tearDown()
29
    {
30
        // TODO Auto-generated ContactControllerFactoryTest::tearDown()
31
        parent::tearDown();
32
    }
33
34
    public function testCreationOfContactControllerViaFactory()
35
    {
36
        $this->markTestSkipped('Some More testing has to be done here');
37
        $contactForm = $this->getMock('\OrgHeiglContact\Form\ContactForm');
0 ignored issues
show
Bug introduced by
The method getMock() does not exist on Org_Heigl\ContactTest\Se...ctControllerFactoryTest. Did you maybe mean getMockBuilder()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
38
        $transport   = $this->getMock('\Zend\Mail\Transport\TransportInterface');
0 ignored issues
show
Bug introduced by
The method getMock() does not exist on Org_Heigl\ContactTest\Se...ctControllerFactoryTest. Did you maybe mean getMockBuilder()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
39
        $message     = $this->getMock('\Zend\Mail\Message');
0 ignored issues
show
Bug introduced by
The method getMock() does not exist on Org_Heigl\ContactTest\Se...ctControllerFactoryTest. Did you maybe mean getMockBuilder()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
40
        $serviceLocator = new ServiceManager();
41
        $serviceLocator->setFactory('message', '\OrgHeiglContact\Services\MailMessageFactory', false);
0 ignored issues
show
Unused Code introduced by
The call to ServiceManager::setFactory() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
42
        $serviceLocator->setFactory('transport', '\OrgHeiglContact\Services\MailTransportFactory', false);
0 ignored issues
show
Unused Code introduced by
The call to ServiceManager::setFactory() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
43
        $serviceLocator->setInvokableClass('OrgHeiglContact\Form\ContactForm', 'OrgHeiglContact\Form\ContactForm', false);
0 ignored issues
show
Unused Code introduced by
The call to ServiceManager::setInvokableClass() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
44
        $serviceManager = new ServiceLocator();
0 ignored issues
show
Unused Code introduced by
$serviceManager is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
45
        $factory = new  ContactControllerFactory();
46
        $controller = $factory->createService($serviceLocator);
0 ignored issues
show
Bug introduced by
The method createService() does not seem to exist on object<Org_Heigl\Contact...ntactControllerFactory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
        $this->assertInstanceOf('\OrgHeiglContact\Controller\ContactController', $controller);        
48
        $this->assertAttributeInstanceOf('\Zend\Mail\Transport\TransportInterface', 'transport', $controller);  
49
        $this->assertAttributeEquals($transport, 'transport', $controller);      
50
        $this->assertAttributeInstanceOf('\Zend\Mail\Message', 'message', $controller);  
51
        $this->assertAttributeEquals($message, 'message', $controller);      
52
        $this->assertAttributeInstanceOf('\OrgHeiglContact\Form\ContactForm', 'form', $controller);        
53
        $this->assertAttributeEquals($contactForm, 'form', $controller);      
54
    }
55
}
56
57