Completed
Push — master ( 9de1be...100987 )
by David
8s
created

InvalidatePathCommandTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 2
dl 37
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testExecute() 16 16 1
A testExecuteVerbose() 17 17 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCacheBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\HttpCacheBundle\Tests\Functional\Command;
13
14
use Symfony\Component\Console\Output\OutputInterface;
15
16 View Code Duplication
class InvalidatePathCommandTest extends CommandTestCase
17
{
18
    public function testExecute()
19
    {
20
        $client = self::createClient();
21
        $client->getContainer()->mock(
0 ignored issues
show
Bug introduced by
The method mock() does not seem to exist on object<Symfony\Component...ion\ContainerInterface>.

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...
22
            'fos_http_cache.cache_manager',
23
            '\FOS\HttpCacheBundle\CacheManager'
24
        )
25
            ->shouldReceive('supports')->andReturn(true)
26
            ->shouldReceive('invalidatePath')->once()->with('http://example.com/my/path')
27
            ->shouldReceive('invalidatePath')->once()->with('http://example.com/other/path')
28
            ->shouldReceive('flush')->once()->andReturn(2)
29
        ;
30
31
        $output = $this->runCommand($client, 'fos:httpcache:invalidate:path http://example.com/my/path http://example.com/other/path');
32
        $this->assertEquals('', $output);
33
    }
34
35
    public function testExecuteVerbose()
36
    {
37
        $client = self::createClient();
38
        $client->getContainer()->mock(
0 ignored issues
show
Bug introduced by
The method mock() does not seem to exist on object<Symfony\Component...ion\ContainerInterface>.

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...
39
            'fos_http_cache.cache_manager',
40
            '\FOS\HttpCacheBundle\CacheManager'
41
        )
42
            ->shouldReceive('supports')->andReturn(true)
43
            ->shouldReceive('invalidatePath')->once()->with('http://example.com/my/path')
44
            ->shouldReceive('invalidatePath')->once()->with('http://example.com/other/path')
45
            ->shouldReceive('flush')->once()->andReturn(2)
46
        ;
47
48
        $output = $this->runCommand($client, 'fos:httpcache:invalidate:path http://example.com/my/path http://example.com/other/path', OutputInterface::VERBOSITY_VERBOSE);
49
50
        $this->assertEquals("Sent 2 invalidation request(s)\n", $output);
51
    }
52
}
53