Skip to content

Commit c998624

Browse files
committed
Testcase for #52
1 parent 12fe105 commit c998624

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/model/parts/TraitsPart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function removeTrait($trait) {
109109

110110
$index = array_search($name, $this->traits);
111111
if ($index !== false) {
112-
unset($this->traits[$name]);
112+
unset($this->traits[$index]);
113113

114114
if ($trait instanceof PhpTrait) {
115115
$qname = $trait->getQualifiedName();

tests/model/ClassTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @group model
1414
*/
1515
class ClassTest extends \PHPUnit_Framework_TestCase {
16-
16+
1717
use ModelAssertions;
1818
use ValueTests;
1919

@@ -163,6 +163,12 @@ public function testTraits() {
163163
$this->assertTrue($class->hasUseStatement('other\name\space\Trait'));
164164
$this->assertSame($class, $class->removeTrait('other\name\space\Trait'));
165165
$this->assertTrue($class->hasUseStatement('other\name\space\Trait'));
166+
167+
$class = new PhpClass('my\name\space\Class');
168+
$class->addTrait('my\trait');
169+
$this->assertEquals(1, count($class->getTraits()));
170+
$class->removeTrait('my\trait');
171+
$this->assertEquals(0, count($class->getTraits()));
166172
}
167173

168174
public function testProperties() {
@@ -227,5 +233,5 @@ public function testDescripion() {
227233
$class->setDescription(['multiline', 'description']);
228234
$this->assertEquals("multiline\ndescription", $class->getDescription());
229235
}
230-
236+
231237
}

0 commit comments

Comments
 (0)