File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public static function fromClassNames(array $classNames)
2020
2121 public function getIterator ()
2222 {
23- return new \ArrayIterator ($ this ->classNames );
23+ return new \ArrayIterator (array_values ( $ this ->classNames ) );
2424 }
2525
2626 public function noneFound (): bool
@@ -41,6 +41,6 @@ public function best(): ClassName
4141
4242 private function add (ClassName $ className )
4343 {
44- $ this ->classNames [] = $ className ;
44+ $ this ->classNames [$ className -> __toString () ] = $ className ;
4545 }
4646}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Phpactor \ClassFileConverter \Tests \Unit \Domain ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+ use Phpactor \ClassFileConverter \Domain \ClassName ;
7+ use Phpactor \ClassFileConverter \Domain \ClassNameCandidates ;
8+
9+ class ClassNameCandidatesTest extends TestCase
10+ {
11+ public function testEnsuresClassNamesAreUnique ()
12+ {
13+ $ candidates = ClassNameCandidates::fromClassNames ([
14+ ClassName::fromString ('Foobar ' ),
15+ ClassName::fromString ('Foobar ' ),
16+ ClassName::fromString ('Barfoo ' ),
17+ ]);
18+
19+ self ::assertCount (2 , $ candidates );
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments