Skip to content

Commit

Permalink
feat(delete): add the missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fnsc committed Sep 30, 2023
1 parent e1ef907 commit b535356
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/Unit/src/Application/DeleterTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace LaravelGoogleDrive\Application;

use LaravelGoogleDrive\Application\Ports\GoogleDriveContract;
use Mockery as m;
use Tests\LeanTestCase;

class DeleterTest extends LeanTestCase
{
public function testShouldGetTheRequestedFile(): void
{
// Set
$googleDrive = m::mock(GoogleDriveContract::class);
/** @phpstan-ignore-next-line */
$deleter = new Deleter($googleDrive);

// Expectations
/** @phpstan-ignore-next-line */
$googleDrive->expects()
->delete('63ab4f34fecd335a6c043105')
->andReturnTrue();

// Action
$result = $deleter->delete('63ab4f34fecd335a6c043105');

// Assertions
$this->assertTrue($result);
}
}
22 changes: 22 additions & 0 deletions tests/Unit/src/Infra/Handlers/GoogleDriveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,26 @@ public function testShouldGetTheRequestedFile(): void
// Assertions
$this->assertInstanceOf(GoogleDriveFile::class, $result);
}

public function testShouldDeleteTheGivenFile(): void
{
// Set
$uploader = m::mock(Uploader::class);
$getter = m::mock(Getter::class);
$deleter = m::mock(Deleter::class);
/** @phpstan-ignore-next-line */
$handler = new GoogleDrive($uploader, $getter, $deleter);

// Expectations
/** @phpstan-ignore-next-line */
$deleter->expects()
->delete('63ab4f34fecd335a6c043104')
->andReturnTrue();

// Action
$result = $handler->delete('63ab4f34fecd335a6c043104');

// Assertions
$this->asserttrue($result);
}
}

0 comments on commit b535356

Please sign in to comment.