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
![]() |
|||
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 | } |