Code Duplication    Length = 28-28 lines in 2 locations

tests/Database/TableTest.php 2 locations

@@ 104-131 (lines=28) @@
101
     * @covers Table::hasIndex
102
     * @covers Table::removeIndex
103
     */
104
    public function testIndexMethods()
105
    {
106
        $table = new FirstTestTable();
107
        $this->assertCount(0, $table->getIndexes());
108
109
        $index = new FirstTestTable\TestIndex();
110
111
        for ($i = 0; $i < 2; $i++) {
112
            try {
113
                $table->addIndex($index);
114
            } catch (InvalidArgumentException $e) {
115
                $this->assertGreaterThan(0, $i);
116
            }
117
            $this->assertCount(1, $table->getIndexes());
118
            $this->assertInstanceOf(FirstTestTable\TestIndex::class, $table->getIndexes()[$index::getName()]);
119
            $this->assertInstanceOf(FirstTestTable\TestIndex::class, $table->getIndex($index::getName()));
120
            $this->assertTrue($table->hasIndex($index::getName()));
121
        }
122
123
        for ($i = 0; $i < 2; $i++) {
124
            try {
125
                $table->removeIndex($index);
126
            } catch (InvalidArgumentException $e) {
127
                $this->assertGreaterThan(0, $i);
128
            }
129
            $this->assertCount(0, $table->getIndexes());
130
        }
131
    }
132
133
    /**
134
     * @covers Table::addUnique
@@ 140-167 (lines=28) @@
137
     * @covers Table::hasUnique
138
     * @covers Table::removeUnique
139
     */
140
    public function testUniqueIndexMethods()
141
    {
142
        $table = new FirstTestTable();
143
        $this->assertCount(0, $table->getUniques());
144
145
        $index = new FirstTestTable\TestUniqueIndex();
146
147
        for ($i = 0; $i < 2; $i++) {
148
            try {
149
                $table->addUnique($index);
150
            } catch (InvalidArgumentException $e) {
151
                $this->assertGreaterThan(0, $i);
152
            }
153
            $this->assertCount(1, $table->getUniques());
154
            $this->assertInstanceOf(FirstTestTable\TestUniqueIndex::class, $table->getUniques()[$index::getName()]);
155
            $this->assertInstanceOf(FirstTestTable\TestUniqueIndex::class, $table->getUnique($index::getName()));
156
            $this->assertTrue($table->hasUnique($index::getName()));
157
        }
158
159
        for ($i = 0; $i < 2; $i++) {
160
            try {
161
                $table->removeUnique($index);
162
            } catch (InvalidArgumentException $e) {
163
                $this->assertGreaterThan(0, $i);
164
            }
165
            $this->assertCount(0, $table->getUniques());
166
        }
167
    }
168
}
169