fix unit tests

This commit is contained in:
Dennis Eichhorn 2020-12-05 22:45:51 +01:00
parent 3fc7c0c233
commit f5ad4345bb
4 changed files with 36 additions and 23 deletions

View File

@ -276,7 +276,7 @@ final class MultiMap implements \Countable
$permutation = Permutation::permut($key, [], false);
foreach ($permutation as $permut) {
if ($this->set(\implode(':', $permut), $value)) {
if ($this->setSingle(\implode(':', $permut), $value)) {
return true;
}
}
@ -284,7 +284,7 @@ final class MultiMap implements \Countable
return false;
}
return $this->set(\implode(':', $key), $value);
return $this->setSingle(\implode(':', $key), $value);
}
/**
@ -340,7 +340,7 @@ final class MultiMap implements \Countable
$key = \is_array($key) ? $key : [$key];
if ($this->orderType !== OrderType::LOOSE) {
return $this->remove(\implode(':', $key));
return $this->removeSingle(\implode(':', $key));
}
/** @var array $keys */
@ -348,7 +348,7 @@ final class MultiMap implements \Countable
$found = false;
foreach ($keys as $key => $value) {
$allFound = $this->remove(\implode(':', $value));
$allFound = $this->removeSingle(\implode(':', $value));
if ($allFound) {
$found = true;
@ -505,14 +505,15 @@ final class MultiMap implements \Countable
private function getSiblingsSingle(int|string $key) : array
{
$siblings = [];
if (!isset($this->keys[$key])) {
return [];
}
if (isset($this->keys[$key])) {
$id = $this->keys[$key];
$id = $this->keys[$key];
foreach ($this->keys as $found => $value) {
if ($value === $id && $found !== $key) {
$siblings[] = $found;
}
foreach ($this->keys as $found => $value) {
if ($value === $id && $found !== $key) {
$siblings[] = $found;
}
}

View File

@ -651,7 +651,7 @@ class MultiMapTest extends \PHPUnit\Framework\TestCase
$map = new MultiMap(KeyType::MULTIPLE);
$map->add(['a', 'b'], 'val2');
$remap = $map->remap(['a', 'b'], ['c', 'd']);
$remap = $map->remap('a', 'b');
self::assertFalse($remap);
}
@ -716,7 +716,7 @@ class MultiMapTest extends \PHPUnit\Framework\TestCase
self::assertFalse($removed);
$removed = $map->remove(['a', 'b']);
self::assertFalse($map->removeKey(['a', 'b']));
self::assertFalse($map->removeKey('a'));
}
/**
@ -753,6 +753,6 @@ class MultiMapTest extends \PHPUnit\Framework\TestCase
self::assertFalse($removed);
$removed = $map->remove(['a', 'b']);
self::assertFalse($map->removeKey(['a', 'b']));
self::assertFalse($map->removeKey('a'));
}
}

View File

@ -665,8 +665,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
public function testNodeNext() : void
{
$dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con);
$dir->next();
self::assertEquals(__DIR__ . '/dirtest/test.txt', $dir->next()->getPath());
self::assertEquals(__DIR__ . '/dirtest/test.txt', $dir->current()->getPath());
}
/**
@ -689,6 +690,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
$dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con);
self::assertEquals('sub', $dir->key());
$dir->next();
self::assertEquals('test.txt', $dir->key());
}
@ -813,8 +815,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
public function testDirname() : void
{
$dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con);
$dir->next();
self::assertEquals('dirtest', $dir->next()->getDirname());
self::assertEquals('dirtest', $dir->current()->getDirname());
}
/**
@ -824,8 +827,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
public function testName() : void
{
$dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con);
$dir->next();
self::assertEquals('test', $dir->next()->getName());
self::assertEquals('test', $dir->current()->getName());
}
/**
@ -835,8 +839,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
public function testBaseame() : void
{
$dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con);
$dir->next();
self::assertEquals('test.txt', $dir->next()->getBasename());
self::assertEquals('test.txt', $dir->current()->getBasename());
}
/**
@ -846,7 +851,8 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
public function testDirpath() : void
{
$dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con);
$dir->next();
self::assertEquals(__DIR__ . '/dirtest', $dir->next()->getDirPath());
self::assertEquals(__DIR__ . '/dirtest', $dir->current()->getDirPath());
}
}

View File

@ -634,8 +634,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
public function testNodeNext() : void
{
$dir = new Directory(__DIR__ . '/dirtest');
$dir->next();
self::assertEquals(__DIR__ . '/dirtest/test.txt', $dir->next()->getPath());
self::assertEquals(__DIR__ . '/dirtest/test.txt', $dir->current()->getPath());
}
/**
@ -658,6 +659,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
$dir = new Directory(__DIR__ . '/dirtest');
self::assertEquals('sub', $dir->key());
$dir->next();
self::assertEquals('test.txt', $dir->key());
}
@ -780,8 +782,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
public function testDirname() : void
{
$dir = new Directory(__DIR__ . '/dirtest');
$dir->next();
self::assertEquals('dirtest', $dir->next()->getDirName());
self::assertEquals('dirtest', $dir->current()->getDirName());
}
/**
@ -791,8 +794,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
public function testName() : void
{
$dir = new Directory(__DIR__ . '/dirtest');
$dir->next();
self::assertEquals('test', $dir->next()->getName());
self::assertEquals('test', $dir->current()->getName());
}
/**
@ -802,8 +806,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
public function testBaseame() : void
{
$dir = new Directory(__DIR__ . '/dirtest');
$dir->next();
self::assertEquals('test.txt', $dir->next()->getBasename());
self::assertEquals('test.txt', $dir->current()->getBasename());
}
/**
@ -813,7 +818,8 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
public function testDirpath() : void
{
$dir = new Directory(__DIR__ . '/dirtest');
$dir->next();
self::assertEquals(__DIR__ . '/dirtest', $dir->next()->getDirPath());
self::assertEquals(__DIR__ . '/dirtest', $dir->current()->getDirPath());
}
}