Skip to content

Commit

Permalink
Organise the tests into folders matching the classes they test
Browse files Browse the repository at this point in the history
  • Loading branch information
duncan3dc committed Oct 30, 2024
1 parent 9768e91 commit dbdf2a0
Show file tree
Hide file tree
Showing 42 changed files with 114 additions and 72 deletions.
4 changes: 2 additions & 2 deletions tests/ArgumentTest.php → tests/Argument/ArgumentTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\Argument;

use League\CLImate\Argument\Argument;
use League\CLImate\Exceptions\InvalidArgumentException;
use League\CLImate\Exceptions\UnexpectedValueException;
use League\CLImate\Tests\TestBase;

class ArgumentTest extends TestBase
{
Expand Down Expand Up @@ -128,7 +129,6 @@ public function it_casts_to_bool_when_defined_only()

/**
* @test
* @doesNotPerformAssertions
*/
public function it_casts_to_bool_when_defined_only_true()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\Decorator\Component;

use League\CLImate\Decorator\Component\Command;
use League\CLImate\Tests\TestBase;

class CommandTest extends TestBase
{
Expand Down
3 changes: 2 additions & 1 deletion tests/AnsiTest.php → tests/Decorator/Parser/AnsiTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\Decorator\Parser;

use League\CLImate\Decorator\Parser\Ansi;
use League\CLImate\Decorator\Parser\NonAnsi;
Expand All @@ -9,6 +9,7 @@
use League\CLImate\Decorator\Tags;
use League\CLImate\TerminalObject;
use League\CLImate\TerminalObject\Router\BasicRouter;
use League\CLImate\Tests\TestBase;
use League\CLImate\Util\System\Linux;
use League\CLImate\Util\System\Windows;
use League\CLImate\Util\UtilFactory;
Expand Down
4 changes: 3 additions & 1 deletion tests/StyleTest.php → tests/Decorator/StyleTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\Decorator;

use League\CLImate\Tests\TestBase;

class StyleTest extends TestBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Basic;

use League\CLImate\Tests\TestBase;

class BorderTest extends TestBase
{
Expand Down
4 changes: 3 additions & 1 deletion tests/BrTest.php → tests/TerminalObject/Basic/BrTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Basic;

use League\CLImate\Tests\TestBase;

class BrTest extends TestBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Basic;

use League\CLImate\Tests\TestBase;

class ClearTest extends TestBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Basic;

class ColumnTest extends TestBase
use League\CLImate\Tests\TestBase;

class ColumnsTest extends TestBase
{
protected function getSingleColumn()
{
Expand Down
12 changes: 7 additions & 5 deletions tests/DrawTest.php → tests/TerminalObject/Basic/DrawTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Basic;

use League\CLImate\Tests\TestBase;

class DrawTest extends TestBase
{
Expand Down Expand Up @@ -73,7 +75,7 @@ public function it_404s_when_it_gets_invalid_art()
public function it_can_take_a_custom_art_directory()
{
$this->drawWorks();
$this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . 'art');
$this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'art');
$this->cli->draw('works');
}

Expand All @@ -84,7 +86,7 @@ public function it_can_take_a_custom_art_directory()
public function it_can_take_a_custom_art_directory_with_a_trailing_slash()
{
$this->drawWorks();
$this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . 'art' . \DIRECTORY_SEPARATOR);
$this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'art' . \DIRECTORY_SEPARATOR);
$this->cli->draw('works');
}

Expand All @@ -95,7 +97,7 @@ public function it_can_take_a_custom_art_directory_with_a_trailing_slash()
public function it_can_chain_the_art_setting()
{
$this->drawWorks();
$this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . 'art')->draw('works');
$this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'art')->draw('works');
}


Expand All @@ -110,7 +112,7 @@ public function testAddArt1()
$this->shouldWrite("\e[m\e[0m");
$this->shouldHavePersisted();

$this->cli->addArt(__DIR__ . "/art/");
$this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . "art/");
$this->cli->draw("art");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Basic;

use League\CLImate\Tests\TestBase;

require_once 'VarDumpMock.php';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Basic;

use League\CLImate\Tests\TestBase;

class FlankTest extends TestBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Basic;

use League\CLImate\Tests\TestBase;

class InlineTest extends TestBase
{
Expand Down
40 changes: 20 additions & 20 deletions tests/TerminalObject/Basic/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,43 @@ class JsonTest extends TestBase
*/
public function it_can_output_an_object_as_json()
{
$json = json_encode((object) [
"cell1" => "Cell 1",
"cell2" => "Cell 2",
"cell3" => "Cell 3",
"cell4" => "Cell 4",
], \JSON_PRETTY_PRINT);
$should_be = json_encode((object) [
'cell1' => 'Cell 1',
'cell2' => 'Cell 2',
'cell3' => 'Cell 3',
'cell4' => 'Cell 4',
], JSON_PRETTY_PRINT);

$this->shouldWrite("\e[m{$json}\e[0m");
$this->shouldWrite("\e[m" . $should_be . "\e[0m");
$this->shouldHavePersisted();

$this->cli->json((object) [
"cell1" => "Cell 1",
"cell2" => "Cell 2",
"cell3" => "Cell 3",
"cell4" => "Cell 4",
]);
'cell1' => 'Cell 1',
'cell2' => 'Cell 2',
'cell3' => 'Cell 3',
'cell4' => 'Cell 4',
]);
}

/**
* We do this test specifically because json escapes the tags,
* we want to make sure we"re taking care of that
* we want to make sure we're taking care of that
*
* @test
* @doesNotPerformAssertions
*/
public function it_can_output_json_with_tags()
{
$json = json_encode((object) [
"cell1" => "Cell 1",
"cell2" => "Cell 2",
"cell3" => "Cell 3",
"cell4" => "Cell 4",
$should_be = json_encode((object) [
"cell1" => 'Cell 1',
"cell2" => 'Cell 2',
"cell3" => 'Cell 3',
"cell4" => 'Cell 4',
], \JSON_PRETTY_PRINT);

$json = str_replace("Cell 4", "\e[5mCell 4\e[0m", $json);
$should_be = str_replace('Cell 4', "\e[5mCell 4\e[0m", $should_be);

$this->shouldWrite("\e[m{$json}\e[0m");
$this->shouldWrite("\e[m" . $should_be . "\e[0m");
$this->shouldHavePersisted();

$this->cli->json((object) [
Expand Down
4 changes: 3 additions & 1 deletion tests/TabTest.php → tests/TerminalObject/Basic/TabTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Basic;

use League\CLImate\Tests\TestBase;

class TabTest extends TestBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Basic;

use League\CLImate\Tests\TestBase;
use League\CLImate\Exceptions\InvalidArgumentException;

class TableTest extends TestBase
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
<?php

namespace League\CLImate\Tests\Animation;
namespace League\CLImate\Tests\TerminalObject\Dynamic;

use League\CLImate\Tests\TestBase;
use Mockery;

class AnimationTest extends TestBase
{
use ExitToTopFrames;
use ExitToBottomFrames;
use ExitToLeftFrames;
use ExitToRightFrames;
use RunFrames;

use Animation\ExitToBottomFrames;
use Animation\ExitToLeftFrames;
use Animation\ExitToRightFrames;
use Animation\ExitToTopFrames;
use Animation\RunFrames;

private function addArt(): void
{
$this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'art');
$this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'art');
}


protected function emptyFrame()
{
$this->shouldWrite("\e[m\e[0m")->ordered();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace League\CLImate\Tests\Animation;
namespace League\CLImate\Tests\TerminalObject\Dynamic\Animation;

trait ExitToBottomFrames
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace League\CLImate\Tests\Animation;
namespace League\CLImate\Tests\TerminalObject\Dynamic\Animation;

trait ExitToLeftFrames
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace League\CLImate\Tests\Animation;
namespace League\CLImate\Tests\TerminalObject\Dynamic\Animation;

trait ExitToRightFrames
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace League\CLImate\Tests\Animation;
namespace League\CLImate\Tests\TerminalObject\Dynamic\Animation;

trait ExitToTopFrames
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace League\CLImate\Tests\Animation;
namespace League\CLImate\Tests\TerminalObject\Dynamic\Animation;

trait RunFrames
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Dynamic;

use League\CLImate\Tests\TestBase;
use League\CLImate\Util\System\Linux;
use League\CLImate\Util\UtilFactory;
use Mockery;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Dynamic;

use League\CLImate\Tests\TestBase;

class ConfirmTest extends TestBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Dynamic;

use League\CLImate\Tests\TestBase;

class InputTest extends TestBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Dynamic;

use League\CLImate\Tests\TestBase;

class PaddingTest extends TestBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Dynamic;

use League\CLImate\Tests\TestBase;

class PasswordTest extends TestBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace League\CLImate\Tests;
namespace League\CLImate\Tests\TerminalObject\Dynamic;

use League\CLImate\Tests\TestBase;
use League\CLImate\Exceptions\UnexpectedValueException;

class ProgressTest extends TestBase
Expand Down
Loading

0 comments on commit dbdf2a0

Please sign in to comment.