Skip to content

Commit

Permalink
fixed testSessionStartupData in FilterComponentTest.php #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef Stich committed May 29, 2024
1 parent 34c653f commit 1e27ad6
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions Test/Case/Controller/Component/FilterComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ public function setUp(): void
$this->Controller->Components->trigger('initialize', array($this->Controller));
}

public function endTest($method)
public function tearDown(): void
{
parent::tearDown();

$this->Controller->Session->destroy();
unset($this->Controller);
}
Expand Down Expand Up @@ -211,28 +213,21 @@ public function testSessionStartupData(): void
$this->assertSame('Filter model not found: FakeNonexistant', $e1->getMessage());
}

$filterValues = array('Document' => array('title' => 'in'));

Check failure on line 216 in Test/Case/Controller/Component/FilterComponentTest.php

View workflow job for this annotation

GitHub Actions / phpstan (8.2)

Unreachable statement - code above always terminates.

Check failure on line 216 in Test/Case/Controller/Component/FilterComponentTest.php

View workflow job for this annotation

GitHub Actions / phpstan (8.2)

Unreachable statement - code above always terminates.
$this->Controller->Session->write($sessionKey, $filterValues);

try {
$this->Controller->Components->trigger('startup', array($this->Controller));
$this->fail('InvalidArgumentException was not thrown');
} catch (InvalidArgumentException $e2) {
$this->assertSame('xxxFilter model not found: FakeNonexistant', $e2->getMessage());
$this->assertSame('Filter model not found: FakeNonexistant', $e2->getMessage());
}
$actualFilterValues = $this->Controller->Document->getFilterValues();
$this->assertEquals(
$filterValues,
$actualFilterValues[$this->Controller->Document->alias]
);

$filterValues = array('Document' => array('title' => 'in'));
$this->Controller->Session->write($sessionKey, $filterValues);

$this->Controller->Components->trigger('startup', array($this->Controller));
$actualFilterValues = $this->Controller->Document->getFilterValues();
$this->assertEquals(
$filterValues,
$actualFilterValues[$this->Controller->Document->alias]
);

$this->Controller->Session->delete($sessionKey);
}

Expand Down

0 comments on commit 1e27ad6

Please sign in to comment.