CartControllerTest::testCartPage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 4
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 20
rs 10
1
<?php
2
3
namespace GGGGino\SkuskuCartBundle\Tests\Service;
4
5
use Doctrine\Common\Persistence\ObjectRepository;
6
use Doctrine\ORM\EntityManager;
7
use Doctrine\ORM\EntityRepository;
8
use GGGGino\SkuskuCartBundle\Model\SkuskuLangInterface;
9
use GGGGino\SkuskuCartBundle\Tests\TestKernel;
10
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
11
12
class CartControllerTest extends WebTestCase
13
{
14
    protected static function createKernel(array $options = [])
15
    {
16
        return new TestKernel();
17
    }
18
19
    /**
20
     * @inheritdoc
21
     */
22
    protected function setUp()
23
    {
24
        $this->client = static::createClient(array('debug' => true));
0 ignored issues
show
Bug Best Practice introduced by
The property client does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
25
26
        // Mock carts
27
        $repoCarts = $this->createMock(EntityRepository::class);
28
        $repoCarts->expects($this->any())
29
            ->method('__call')
30
            ->with(
31
                $this->equalTo('findOneByCustomer')
32
            )
33
            //->method('findOneByCustomer')
34
            ->willReturn(null);
35
36
        // Last, mock the EntityManager to return the mock of the repository
37
        $objectManager = $this->createMock(EntityManager::class);
38
        $objectManager->expects($this->any())
39
            ->method('getRepository')
40
            ->with($this->equalTo('GGGGino\SkuskuCartBundle\Model\SkuskuCart'))
41
            ->willReturn($repoCarts);
42
43
        static::$kernel->getContainer()->set('doctrine.orm.default_entity_manager', $objectManager);
44
    }
45
46
    public function testCartPage()
47
    {
48
        $client = static::createClient(array('debug' => true));
49
50
        $this->assertEquals(200, 200);
51
52
        $client->request('GET', '/cart');
53
//        $exceptionProfile = $client->getProfile()->getCollector('exception');
54
//
55
//        if ($exceptionProfile->hasException()) {
56
//            $message = sprintf(
57
//                "No exception was expected but got '%s' with message '%s'. Trace:\n%s",
58
//                get_class($exceptionProfile->getException()),
59
//                $exceptionProfile->getMessage(),
60
//                $exceptionProfile->getException()->getTraceAsString()
61
//            );
62
//            throw new \Exception($message);
63
//        }
64
65
        $this->assertEquals(500, $client->getResponse()->getStatusCode());
66
    }
67
}