Skip to content

Commit

Permalink
Tidy up the default TestCase class
Browse files Browse the repository at this point in the history
  • Loading branch information
duncan3dc committed Oct 30, 2024
1 parent bd01721 commit 6044c4b
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions tests/TestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
use League\CLImate\Util\Output;
use League\CLImate\Util\Reader\Stdin;
use League\CLImate\Util\System\Linux;
use League\CLImate\Util\UtilFactory;
use Mockery;
use PHPUnit\Framework\TestCase;

class TestBase extends TestCase
abstract class TestBase extends TestCase
{
public static $functions;

/** @var League\CLImate\CLImate */
/** @var CLImate */
public $cli;

/** @var League\CLImate\Util\Output|Mockery\MockInterface */
/** @var Output|Mockery\MockInterface */
public $output;

/** @var League\CLImate\Util\Reader\Stdin|Mockery\MockInterface */
/** @var Stdin|Mockery\MockInterface */
public $reader;

/** @var League\CLImate\Util\UtilFactory */
/** @var UtilFactory */
public $util;

protected $record_it = false;

public function setUp(): void
{
Expand All @@ -35,17 +35,13 @@ public function setUp(): void
$system->shouldReceive('hasAnsiSupport')->andReturn(true);
$system->shouldReceive('width')->andReturn(80);

$this->util = new \League\CLImate\Util\UtilFactory($system);
$this->util = new UtilFactory($system);
$this->output = Mockery::mock(Output::class);
$this->reader = Mockery::mock(Stdin::class);

$this->cli = new CLImate();
$this->cli->setOutput($this->output);
$this->cli->setUtil($this->util);

if (method_exists($this, 'internalSetup')) {
$this->internalSetup();
}
}

public function tearDown(): void
Expand All @@ -61,10 +57,6 @@ public function tearDown(): void
*/
protected function shouldWrite($content, $count = 1)
{
if ($this->record_it) {
file_put_contents('test-log', $content, FILE_APPEND);
}

return $this->output->shouldReceive('write')->times($count)->with($content);
}

Expand Down Expand Up @@ -121,13 +113,4 @@ protected function shouldStopPersisting($times = 1)
{
$this->output->shouldReceive('persist')->with(false)->times($times)->andReturn($this->output);
}

/**
* @test
* @doesNotPerformAssertions
*/
public function it_does_nothing()
{
// nada
}
}

0 comments on commit 6044c4b

Please sign in to comment.