Skip to content

Commit

Permalink
Merge pull request #27 from inpsyde/fix_unit_tests
Browse files Browse the repository at this point in the history
fix unit testing
  • Loading branch information
Chrico authored Jul 11, 2024
2 parents 73b40f9 + a877a89 commit a623d03
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/phpunit/Unit/Settings/SettingsPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public function testBasic(): void
{
$view = Mockery::mock(SettingsPageViewInterface::class);
$view->shouldReceive('name')
->once()
->andReturn();

$view->shouldReceive('slug')
->andReturn();

$repo = Mockery::mock(SettingsRepository::class);
Expand Down Expand Up @@ -53,10 +55,10 @@ public function testRegister(): void

$view = Mockery::mock(SettingsPageViewInterface::class);
$view->shouldReceive('name')
->times(3)
->times(2)
->andReturn('foo');
$view->shouldReceive('slug')
->once()
->times(2)
->andReturn('baz');

$auth = Mockery::mock(SettingsPageAuthInterface::class);
Expand Down Expand Up @@ -87,6 +89,8 @@ public function testUpdateWrongRequestMethod(): void
$view = Mockery::mock(SettingsPageViewInterface::class);
$view->shouldReceive('name')
->andReturn();
$view->shouldReceive('slug')
->andReturn();

$repo = Mockery::mock(SettingsRepository::class);
$auth = Mockery::mock(SettingsPageAuthInterface::class);
Expand All @@ -106,6 +110,9 @@ public function testUpdateUpdateFails(): void
$view->shouldReceive('name')
->andReturn();

$view->shouldReceive('slug')
->andReturn();

$repo = Mockery::mock(SettingsRepository::class);
$repo->shouldReceive('options')
->andReturn([]);
Expand All @@ -130,7 +137,9 @@ public function testAddElement(): void
{
$view = Mockery::mock(SettingsPageViewInterface::class);
$view->shouldReceive('name')
->once()
->andReturn();

$view->shouldReceive('slug')
->andReturn();

$repo = Mockery::mock(SettingsRepository::class);
Expand All @@ -140,6 +149,8 @@ public function testAddElement(): void
$element = Mockery::mock(ElementInterface::class);
$element->shouldReceive('name')
->andReturn('');
$element->shouldReceive('withParent')
->andReturn();

$testee = new SettingsPage($view, $repo, $auth);
static::assertNull($testee->addElement($element));
Expand Down

0 comments on commit a623d03

Please sign in to comment.