Improve code readability for exists method (#5022)

This commit is contained in:
Marc Jauvin 2020-04-02 10:33:58 -04:00 committed by GitHub
parent 9aa6b9d9d1
commit 600fbd7cfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -338,7 +338,7 @@ class PluginManager
*/
public function exists($id)
{
return !(!$this->findByIdentifier($id) || $this->isDisabled($id));
return $this->findByIdentifier($id) && !$this->isDisabled($id);
}
/**

View File

@ -225,4 +225,19 @@ class PluginManagerTest extends TestCase
$result = $this->manager->isDisabled('dependencytest.notfound');
$this->assertTrue($result);
}
public function testExists()
{
$result = $this->manager->exists('DependencyTest.Found');
$this->assertTrue($result);
$result = $this->manager->exists('DependencyTest.WrongCase');
$this->assertTrue($result);
$result = $this->manager->exists('DependencyTest.NotFound');
$this->assertFalse($result);
$result = $this->manager->exists('Unknown.Plugin');
$this->assertFalse($result);
}
}