Code Duplication    Length = 30-30 lines in 2 locations

LoggedInCustomerDetailsActionTest.php 2 locations

@@ 16-45 (lines=30) @@
13
    /**
14
     * @test
15
     */
16
    public function it_shows_currently_logged_in_customer_details()
17
    {
18
        $this->loadFixturesFromFile('customer.yml');
19
        $this->loadFixturesFromFile('channel.yml');
20
21
        $fakeChannelContext = $this->createMock(ChannelContextInterface::class);
22
        $fakeChannelContext->method('getChannel')->willReturn($this->get('sylius.repository.channel')->findOneByCode('WEB_GB'));
23
        $this->client->getContainer()->set('sylius.context.channel', $fakeChannelContext);
24
25
        $data =
26
<<<EOT
27
        {
28
            "_username": "[email protected]",
29
            "_password": "123pa\$\$word"
30
        }
31
EOT;
32
33
        $this->client->request('POST', '/shop-api/login_check', [], [], ['CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json'], $data);
34
35
        $response = json_decode($this->client->getResponse()->getContent(), true);
36
        $this->client->setServerParameter('HTTP_Authorization', sprintf('Bearer %s', $response['token']));
37
38
        $this->client->request('GET', '/shop-api/me', [], [], [
39
            'CONTENT_TYPE' => 'application/json',
40
            'ACCEPT' => 'application/json',
41
        ]);
42
43
        $response = $this->client->getResponse();
44
        $this->assertResponse($response, 'customer/logged_in_customer_details_response', Response::HTTP_OK);
45
    }
46
47
    /**
48
     * @test
@@ 50-79 (lines=30) @@
47
    /**
48
     * @test
49
     */
50
    public function it_shows_currently_logged_in_customer_addresses()
51
    {
52
        $this->loadFixturesFromFile('customer.yml');
53
        $this->loadFixturesFromFile('channel.yml');
54
55
        $fakeChannelContext = $this->createMock(ChannelContextInterface::class);
56
        $fakeChannelContext->method('getChannel')->willReturn($this->get('sylius.repository.channel')->findOneByCode('WEB_GB'));
57
        $this->client->getContainer()->set('sylius.context.channel', $fakeChannelContext);
58
59
        $data =
60
            <<<EOT
61
        {
62
            "_username": "[email protected]",
63
            "_password": "123pa\$\$word"
64
        }
65
EOT;
66
67
        $this->client->request('POST', '/shop-api/login_check', [], [], ['CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json'], $data);
68
69
        $response = json_decode($this->client->getResponse()->getContent(), true);
70
        $this->client->setServerParameter('HTTP_Authorization', sprintf('Bearer %s', $response['token']));
71
72
        $this->client->request('GET', '/shop-api/me/address', [], [], [
73
            'CONTENT_TYPE' => 'application/json',
74
            'ACCEPT' => 'application/json',
75
        ]);
76
77
        $response = $this->client->getResponse();
78
        $this->assertResponse($response, 'customer/logged_in_customer_addresses', Response::HTTP_OK);
79
    }
80
}
81