Completed
Push — master ( 4025c4...856f8c )
by Nikita
02:41
created

IndexTest::testAll()   B

Complexity

Conditions 6
Paths 18

Size

Total Lines 36
Code Lines 25

Duplication

Lines 16
Ratio 44.44 %

Importance

Changes 0
Metric Value
dl 16
loc 36
rs 8.439
c 0
b 0
f 0
cc 6
eloc 25
nc 18
nop 0
1
<?php
2
3
namespace Taisiya\PropelBundle\Database;
4
5
use Taisiya\PropelBundle\Database\Exception\InvalidArgumentException;
6
use Taisiya\PropelBundle\Database\TestDatabase\FirstTestTable\IdColumn;
7
use Taisiya\PropelBundle\Database\TestDatabase\FirstTestTable\TestIndex;
8
use Taisiya\PropelBundle\PHPUnitTestCase;
9
10
class IndexTest extends PHPUnitTestCase
11
{
12
    /**
13
     * @covers Index::addColumn
14
     * @covers Index::addColumnIfNotExists
15
     * @covers Index::getColumns
16
     * @covers Index::findIndexColumnByName
17
     * @covers Index::removeColumn
18
     */
19
    public function testAll()
20
    {
21
        $index = new TestIndex();
22
23 View Code Duplication
        for ($i = 0; $i < 2; $i++) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
            try {
25
                $index->addColumn(new IdColumn());
26
            } catch (InvalidArgumentException $e) {
27
                $this->assertGreaterThan(0, $i);
28
            }
29
            $this->assertCount(1, $index->getColumns());
30
            $this->assertInstanceOf(IdColumn::class, $index->getColumns()[0]->getColumn());
31
            $this->assertNull($index->findIndexColumnByName(IdColumn::getName())->getSize());
32
        }
33
34
        for ($i = 0; $i < 2; $i++) {
35
            try {
36
                $index->removeColumn(IdColumn::getName());
37
            } catch (InvalidArgumentException $e) {
38
                $this->assertGreaterThan(0, $i);
39
            }
40
            $this->assertCount(0, $index->getColumns());
41
        }
42
43 View Code Duplication
        for ($i = 0; $i < 2; $i++) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
            $index->addColumnIfNotExists(new IdColumn(), 255);
45
            $this->assertCount(1, $index->getColumns());
46
            $this->assertInstanceOf(IdColumn::class, $index->getColumns()[0]->getColumn());
47
            $this->assertSame(255, $index->findIndexColumnByName(IdColumn::getName())->getSize());
48
        }
49
50
        $index->addColumnIfNotExists(new IdColumn(), 32);
51
        $this->assertCount(1, $index->getColumns());
52
        $this->assertInstanceOf(IdColumn::class, $index->getColumns()[0]->getColumn());
53
        $this->assertSame(32, $index->findIndexColumnByName(IdColumn::getName())->getSize());
54
    }
55
}
56