RemoveNotFoundSubscriberTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addTestData() 0 10 1
A delete_not_found_on_create_redirect() 0 9 1
A delete_not_found_on_update_redirect() 0 10 1
1
<?php
2
3
namespace Zenstruck\RedirectBundle\Tests\Functional;
4
5
use Zenstruck\RedirectBundle\Tests\Fixture\Bundle\Entity\DummyNotFound;
6
use Zenstruck\RedirectBundle\Tests\Fixture\Bundle\Entity\DummyRedirect;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
class RemoveNotFoundSubscriberTest extends FunctionalTest
12
{
13
    public function addTestData()
14
    {
15
        parent::addTestData();
16
17
        $this->em->persist(new DummyNotFound('/foo', 'http://example.com/foo'));
18
        $this->em->persist(new DummyNotFound('/foo', 'http://example.com/foo?bar=foo'));
19
        $this->em->persist(new DummyNotFound('/bar', 'http://example.com/bar'));
20
21
        $this->em->flush();
22
    }
23
24
    /**
25
     * @test
26
     */
27
    public function delete_not_found_on_create_redirect()
28
    {
29
        $this->assertCount(3, $this->getNotFounds());
30
31
        $this->em->persist(new DummyRedirect('/foo', '/bar'));
32
        $this->em->flush();
33
34
        $this->assertCount(1, $this->getNotFounds());
35
    }
36
37
    /**
38
     * @test
39
     */
40
    public function delete_not_found_on_update_redirect()
41
    {
42
        $this->assertCount(3, $this->getNotFounds());
43
44
        $redirect = $this->getRedirect('/301-redirect');
45
        $redirect->setSource('/foo');
46
        $this->em->flush();
47
48
        $this->assertCount(1, $this->getNotFounds());
49
    }
50
}
51