Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d83e437b4a | |||
| 99d554e5d7 | |||
| 75dd7494c3 | |||
| f7504bbb60 |
+1
-2
@@ -55,9 +55,8 @@ class Action
|
||||
|
||||
/**
|
||||
* @param string|null $title
|
||||
* @return string|null
|
||||
*/
|
||||
public function setTitle(?string $title): ?string
|
||||
public function setTitle(?string $title): void
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
@@ -202,11 +202,17 @@ class Scene implements CreateableInterface, SceneConnectable
|
||||
/**
|
||||
* Returns a connection group entity associated with this scene by a given name.
|
||||
* @param string $name
|
||||
* @return SceneConnectionGroup
|
||||
* @return SceneConnectionGroup|null
|
||||
*/
|
||||
public function getConnectionGroup(string $name): SceneConnectionGroup
|
||||
public function getConnectionGroup(string $name): ?SceneConnectionGroup
|
||||
{
|
||||
return $this->filterConnectionGroupCollectionByName($name)->first();
|
||||
$filtered = $this->filterConnectionGroupCollectionByName($name)->first();
|
||||
|
||||
if (!$filtered) {
|
||||
return null;
|
||||
} else {
|
||||
return $filtered;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,8 +78,7 @@ class HasAction extends Constraint
|
||||
$checkedOnce = True;
|
||||
}
|
||||
|
||||
# Using KNF, !A or B is only false if A is true and B is not.
|
||||
if ($action->$methodToCheck() == $valueToHave and (!is_null($groupTitle) or $group->getTitle() === $groupTitle)) {
|
||||
if ($action->$methodToCheck() == $valueToHave and (is_null($groupTitle) or $group->getTitle() === $groupTitle)) {
|
||||
$found = $action;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ class LotGDTestCase extends TestCase
|
||||
}
|
||||
|
||||
# Using KNF, !A or B is only false if A is true and B is not.
|
||||
if ($action->$methodToCheck() == $valueToHave and (!is_null($groupTitle) or $group->getTitle() === $groupTitle)) {
|
||||
if ($action->$methodToCheck() == $valueToHave and (is_null($groupTitle) or $group->getTitle() === $groupTitle)) {
|
||||
$found = $action;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,4 +364,21 @@ class SceneModelTest extends CoreModelTestCase
|
||||
$this->expectException(ArgumentException::class);
|
||||
$scene1->getConnectionGroup("lotgd/tests/village/hidden")->connect($scene2->getConnectionGroup("lotgd/tests/forest/category"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://github.com/lotgd/core/issues/150
|
||||
*/
|
||||
public function testIfGetConnectionGroupReturnsNullAndDoesNotThrowATypeError()
|
||||
{
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
|
||||
# Positively assert that this usually works
|
||||
$connectionGroup = $scene1->getConnectionGroup("lotgd/tests/village/empty");
|
||||
$this->assertNotNull($connectionGroup);
|
||||
$this->assertInstanceOf(SceneConnectionGroup::class, $connectionGroup);
|
||||
|
||||
# Assert that connectionGroup is null if it does not exist.
|
||||
$connectionGroup = $scene1->getConnectionGroup("this-does-not-exist");
|
||||
$this->assertNull($connectionGroup);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user