diff --git a/tests/CLImateTest.php b/tests/CLImateTest.php
index 29ed0f92..c26ca190 100644
--- a/tests/CLImateTest.php
+++ b/tests/CLImateTest.php
@@ -4,8 +4,11 @@
use League\CLImate\Exceptions\InvalidArgumentException;
use League\CLImate\Exceptions\UnexpectedValueException;
+use League\CLImate\Tests\CustomObject\Basic;
use League\CLImate\Tests\CustomObject\BasicObject;
use League\CLImate\Tests\CustomObject\BasicObjectArgument;
+use League\CLImate\Tests\CustomObject\Dummy;
+use League\CLImate\Tests\CustomObject\Dynamic;
class CLImateTest extends TestBase
{
@@ -57,7 +60,7 @@ public function it_can_be_extended_using_a_basic_object_as_string()
$this->shouldWrite("\e[mBy Custom Object: This is something my custom object is handling.\e[0m");
$this->shouldHavePersisted();
- $this->cli->extend('League\CLImate\Tests\CustomObject\Basic');
+ $this->cli->extend(Basic::class);
$this->cli->basic('This is something my custom object is handling.');
}
@@ -90,16 +93,16 @@ public function it_can_be_extended_using_a_basic_object_with_argument_setter()
/** @test */
public function it_can_be_extended_using_a_dynamic_object()
{
- $this->cli->extend('League\CLImate\Tests\CustomObject\Dynamic');
+ $this->cli->extend(Dynamic::class);
$obj = $this->cli->dynamic();
- $this->assertInstanceOf('League\CLImate\Tests\CustomObject\Dynamic', $obj);
+ $this->assertInstanceOf(Dynamic::class, $obj);
}
/** @test */
public function it_will_yell_if_extending_and_class_doesnt_exist()
{
- $class = 'League\CLImate\Tests\CustomObject\NowhereToBeFound';
+ $class = "NoSuchClass";
$this->expectException(UnexpectedValueException::class);
$this->expectExceptionMessage("Class does not exist: {$class}");
$this->cli->extend($class);
@@ -108,7 +111,7 @@ public function it_will_yell_if_extending_and_class_doesnt_exist()
/** @test */
public function it_will_yell_if_it_doesnt_implement_proper_interfaces()
{
- $class = 'League\CLImate\Tests\CustomObject\Dummy';
+ $class = Dummy::class;
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage("Class must implement either");
$this->cli->extend($class);
@@ -123,7 +126,7 @@ public function it_will_accept_a_custom_key_for_an_extension()
$this->shouldWrite("\e[mBy Custom Object: This is something my custom object is handling.\e[0m");
$this->shouldHavePersisted();
- $this->cli->extend('League\CLImate\Tests\CustomObject\Basic', 'myCustomMethod');
+ $this->cli->extend(Basic::class, 'myCustomMethod');
$this->cli->myCustomMethod('This is something my custom object is handling.');
}
@@ -134,8 +137,8 @@ public function it_will_accept_an_array_of_extensions()
$this->shouldHavePersisted();
$extensions = [
- 'League\CLImate\Tests\CustomObject\Basic',
- 'League\CLImate\Tests\CustomObject\Dynamic',
+ Basic::class,
+ Dynamic::class,
];
$this->cli->extend($extensions);
@@ -144,7 +147,7 @@ public function it_will_accept_an_array_of_extensions()
$obj = $this->cli->dynamic();
- $this->assertInstanceOf('League\CLImate\Tests\CustomObject\Dynamic', $obj);
+ $this->assertInstanceOf(Dynamic::class, $obj);
}
/** @test */
@@ -154,8 +157,8 @@ public function it_will_accept_an_array_of_extensions_with_custom_keys()
$this->shouldHavePersisted();
$extensions = [
- 'whatever' => 'League\CLImate\Tests\CustomObject\Basic',
- 'something' => 'League\CLImate\Tests\CustomObject\Dynamic',
+ 'whatever' => Basic::class,
+ 'something' => Dynamic::class,
];
$this->cli->extend($extensions);
@@ -164,6 +167,6 @@ public function it_will_accept_an_array_of_extensions_with_custom_keys()
$obj = $this->cli->something();
- $this->assertInstanceOf('League\CLImate\Tests\CustomObject\Dynamic', $obj);
+ $this->assertInstanceOf(Dynamic::class, $obj);
}
}
diff --git a/tests/Decorator/Parser/AnsiTest.php b/tests/Decorator/Parser/AnsiTest.php
index b4350e22..b849ab0b 100644
--- a/tests/Decorator/Parser/AnsiTest.php
+++ b/tests/Decorator/Parser/AnsiTest.php
@@ -7,7 +7,7 @@
use League\CLImate\Decorator\Parser\ParserFactory;
use League\CLImate\Decorator\Style;
use League\CLImate\Decorator\Tags;
-use League\CLImate\TerminalObject;
+use League\CLImate\TerminalObject\Basic\BasicTerminalObject;
use League\CLImate\TerminalObject\Router\BasicRouter;
use League\CLImate\Tests\TestBase;
use League\CLImate\Util\System\Linux;
@@ -28,7 +28,8 @@ public function it_can_output_with_ansi()
$style = new Style();
$parser = new Ansi($style->current(), new Tags($style->all()));
- $obj = Mockery::mock('League\CLImate\TerminalObject');
+
+ $obj = Mockery::mock(BasicTerminalObject::class);
$obj->shouldReceive('result')->once()->andReturn("I am green");
$obj->shouldReceive('sameLine')->once()->andReturn(false);
$obj->shouldReceive('getParser')->once()->andReturn($parser);
@@ -52,7 +53,7 @@ public function it_can_output_without_ansi()
$style = new Style();
$parser = new NonAnsi($style->current(), new Tags($style->all()));
- $obj = Mockery::mock('League\CLImate\TerminalObject');
+ $obj = Mockery::mock(BasicTerminalObject::class);
$obj->shouldReceive('result')->once()->andReturn("I am not green");
$obj->shouldReceive('sameLine')->once()->andReturn(false);
$obj->shouldReceive('getParser')->once()->andReturn($parser);
@@ -67,12 +68,12 @@ public function it_can_output_without_ansi()
/** @test */
public function it_will_recognize_non_ansi_systems()
{
- $system = Mockery::mock('League\CLImate\Util\System\Windows');
+ $system = Mockery::mock(Windows::class);
$system->shouldReceive('hasAnsiSupport')->andReturn(false);
$parser = ParserFactory::getInstance($system, [], new Tags([]));
- $this->assertInstanceOf('League\CLImate\Decorator\Parser\NonAnsi', $parser);
+ $this->assertInstanceOf(NonAnsi::class, $parser);
}
/**
diff --git a/tests/TerminalObject/Dynamic/Animation/AnimationTest.php b/tests/TerminalObject/Dynamic/Animation/AnimationTest.php
index 2806cb6b..4f16d07a 100644
--- a/tests/TerminalObject/Dynamic/Animation/AnimationTest.php
+++ b/tests/TerminalObject/Dynamic/Animation/AnimationTest.php
@@ -2,6 +2,7 @@
namespace League\CLImate\Tests\TerminalObject\Dynamic;
+use League\CLImate\TerminalObject\Helper\Sleeper;
use League\CLImate\Tests\TestBase;
use Mockery;
@@ -37,7 +38,7 @@ protected function blankLines($count = 1)
protected function getSleeper($count)
{
- $sleeper = Mockery::mock('League\CLImate\TerminalObject\Helper\Sleeper');
+ $sleeper = Mockery::mock(Sleeper::class);
$sleeper->shouldReceive('sleep')->times($count);
return $sleeper;
diff --git a/tests/TestBase.php b/tests/TestBase.php
index d67b9f84..118138b8 100644
--- a/tests/TestBase.php
+++ b/tests/TestBase.php
@@ -3,6 +3,9 @@
namespace League\CLImate\Tests;
use League\CLImate\CLImate;
+use League\CLImate\Util\Output;
+use League\CLImate\Util\Reader\Stdin;
+use League\CLImate\Util\System\Linux;
use Mockery;
use PHPUnit\Framework\TestCase;
@@ -28,13 +31,13 @@ public function setUp(): void
{
self::$functions = Mockery::mock();
- $system = Mockery::mock('League\CLImate\Util\System\Linux');
+ $system = Mockery::mock(Linux::class);
$system->shouldReceive('hasAnsiSupport')->andReturn(true);
$system->shouldReceive('width')->andReturn(80);
$this->util = new \League\CLImate\Util\UtilFactory($system);
- $this->output = Mockery::mock('League\CLImate\Util\Output');
- $this->reader = Mockery::mock('League\CLImate\Util\Reader\Stdin');
+ $this->output = Mockery::mock(Output::class);
+ $this->reader = Mockery::mock(Stdin::class);
$this->cli = new CLImate();
$this->cli->setOutput($this->output);
diff --git a/tests/Util/OutputTest.php b/tests/Util/OutputTest.php
index e3da9cf2..148703b5 100644
--- a/tests/Util/OutputTest.php
+++ b/tests/Util/OutputTest.php
@@ -5,6 +5,9 @@
use League\CLImate\Exceptions\InvalidArgumentException;
use League\CLImate\Tests\TestBase;
use League\CLImate\Util\Output;
+use League\CLImate\Util\Writer\Buffer;
+use League\CLImate\Util\Writer\StdErr;
+use League\CLImate\Util\Writer\StdOut;
use Mockery;
use function get_class;
@@ -17,7 +20,7 @@ class OutputTest extends TestBase
*/
public function it_can_output_content()
{
- $out = Mockery::mock('League\CLImate\Util\Writer\StdOut');
+ $out = Mockery::mock(StdOut::class);
$out->shouldReceive('write')->once()->with("Oh, hey there." . \PHP_EOL);
$output = new Output();
@@ -33,7 +36,7 @@ public function it_can_output_content()
*/
public function it_can_output_content_without_a_new_line()
{
- $out = Mockery::mock('League\CLImate\Util\Writer\StdOut');
+ $out = Mockery::mock(StdOut::class);
$out->shouldReceive('write')->once()->with("Oh, hey there.");
$output = new Output();
@@ -49,7 +52,7 @@ public function it_can_output_content_without_a_new_line()
*/
public function it_can_default_to_a_writer()
{
- $error = Mockery::mock('League\CLImate\Util\Writer\StdErr');
+ $error = Mockery::mock(StdErr::class);
$error->shouldReceive('write')->once()->with("Oh, hey there.");
$output = new Output();
@@ -66,10 +69,10 @@ public function it_can_default_to_a_writer()
*/
public function it_can_default_to_multiple_writers()
{
- $out = Mockery::mock('League\CLImate\Util\Writer\StdOut');
+ $out = Mockery::mock(StdOut::class);
$out->shouldReceive('write')->once()->with("Oh, hey there.");
- $error = Mockery::mock('League\CLImate\Util\Writer\StdErr');
+ $error = Mockery::mock(StdErr::class);
$error->shouldReceive('write')->once()->with("Oh, hey there.");
$output = new Output();
@@ -87,10 +90,10 @@ public function it_can_default_to_multiple_writers()
*/
public function it_can_add_a_default()
{
- $out = Mockery::mock('League\CLImate\Util\Writer\StdOut');
+ $out = Mockery::mock(StdOut::class);
$out->shouldReceive('write')->once()->with("Oh, hey there.");
- $error = Mockery::mock('League\CLImate\Util\Writer\StdErr');
+ $error = Mockery::mock(StdErr::class);
$error->shouldReceive('write')->once()->with("Oh, hey there.");
$output = new Output();
@@ -109,10 +112,10 @@ public function it_can_add_a_default()
*/
public function it_can_handle_multiple_writers_for_one_key()
{
- $out = Mockery::mock('League\CLImate\Util\Writer\StdOut');
+ $out = Mockery::mock(StdOut::class);
$out->shouldReceive('write')->once()->with('Oh, hey there.');
- $error = Mockery::mock('League\CLImate\Util\Writer\StdErr');
+ $error = Mockery::mock(StdErr::class);
$error->shouldReceive('write')->once()->with('Oh, hey there.');
$output = new Output();
@@ -129,10 +132,10 @@ public function it_can_handle_multiple_writers_for_one_key()
*/
public function it_can_take_existing_writer_keys_and_resolve_them()
{
- $out = Mockery::mock('League\CLImate\Util\Writer\StdOut');
+ $out = Mockery::mock(StdOut::class);
$out->shouldReceive('write')->once()->with('Oh, hey there.');
- $error = Mockery::mock('League\CLImate\Util\Writer\StdErr');
+ $error = Mockery::mock(StdErr::class);
$error->shouldReceive('write')->once()->with('Oh, hey there.');
$output = new Output();
@@ -148,9 +151,9 @@ public function it_can_take_existing_writer_keys_and_resolve_them()
/** @test */
public function it_can_get_the_available_writers()
{
- $out = Mockery::mock('League\CLImate\Util\Writer\StdOut');
- $error = Mockery::mock('League\CLImate\Util\Writer\StdErr');
- $buffer = Mockery::mock('League\CLImate\Util\Writer\Buffer');
+ $out = Mockery::mock(StdOut::class);
+ $error = Mockery::mock(StdErr::class);
+ $buffer = Mockery::mock(Buffer::class);
$output = new Output();
@@ -185,7 +188,7 @@ public function it_can_get_the_available_writers()
/** @test */
public function it_will_yell_if_writer_does_not_implement_writer_interface()
{
- $out = Mockery::mock('League\CLImate\Util\Writer\Wat');
+ $out = Mockery::mock();
$output = new Output();
$this->expectException(InvalidArgumentException::class);
@@ -211,10 +214,10 @@ public function it_will_yell_if_trying_to_add_a_non_existent_nested_writer_key()
*/
public function it_can_write_to_a_non_default_writer_once()
{
- $out = Mockery::mock('League\CLImate\Util\Writer\StdOut');
+ $out = Mockery::mock(StdOut::class);
$out->shouldReceive('write')->once()->with('Second time.');
- $error = Mockery::mock('League\CLImate\Util\Writer\StdErr');
+ $error = Mockery::mock(StdErr::class);
$error->shouldReceive('write')->once()->with('First time.');
$output = new Output();
@@ -234,10 +237,10 @@ public function it_can_write_to_a_non_default_writer_once()
*/
public function it_will_persist_writer_if_told_to()
{
- $out = Mockery::mock('League\CLImate\Util\Writer\StdOut');
+ $out = Mockery::mock(StdOut::class);
$out->shouldReceive('write')->once()->with('Second time.');
- $error = Mockery::mock('League\CLImate\Util\Writer\StdErr');
+ $error = Mockery::mock(StdErr::class);
$error->shouldReceive('write')->times(3)->with('First time.');
$output = new Output();
@@ -258,7 +261,7 @@ public function it_will_persist_writer_if_told_to()
/** @test */
public function it_can_retrieve_a_writer()
{
- $buffer = Mockery::mock('League\CLImate\Util\Writer\Buffer');
+ $buffer = Mockery::mock(Buffer::class);
$buffer->shouldReceive('write')->once()->with('Oh, hey there.');
$buffer->shouldReceive('get')->once()->andReturn('Oh, hey there.');
diff --git a/tests/Util/System/LinuxTest.php b/tests/Util/System/LinuxTest.php
index 44d1b0a7..8d323e5c 100644
--- a/tests/Util/System/LinuxTest.php
+++ b/tests/Util/System/LinuxTest.php
@@ -3,6 +3,7 @@
namespace League\CLImate\Tests\Util\System;
use League\CLImate\Tests\TestBase;
+use League\CLImate\Util\System\Linux;
use Mockery;
class LinuxTest extends TestBase
@@ -10,7 +11,7 @@ class LinuxTest extends TestBase
/** @test */
public function it_can_get_the_width()
{
- $system = Mockery::mock('League\CLImate\Util\System\Linux')
+ $system = Mockery::mock(Linux::class)
->makePartial()
->shouldAllowMockingProtectedMethods();
@@ -22,7 +23,7 @@ public function it_can_get_the_width()
/** @test */
public function it_will_return_null_if_width_is_not_numeric()
{
- $system = Mockery::mock('League\CLImate\Util\System\Linux')
+ $system = Mockery::mock(Linux::class)
->makePartial()
->shouldAllowMockingProtectedMethods();
@@ -34,7 +35,7 @@ public function it_will_return_null_if_width_is_not_numeric()
/** @test */
public function it_can_get_the_height()
{
- $system = Mockery::mock('League\CLImate\Util\System\Linux')
+ $system = Mockery::mock(Linux::class)
->makePartial()
->shouldAllowMockingProtectedMethods();
@@ -46,7 +47,7 @@ public function it_can_get_the_height()
/** @test */
public function it_will_return_null_if_height_is_not_numeric()
{
- $system = Mockery::mock('League\CLImate\Util\System\Linux')
+ $system = Mockery::mock(Linux::class)
->makePartial()
->shouldAllowMockingProtectedMethods();
diff --git a/tests/Util/System/WindowsTest.php b/tests/Util/System/WindowsTest.php
index 19cd7fc0..46940251 100644
--- a/tests/Util/System/WindowsTest.php
+++ b/tests/Util/System/WindowsTest.php
@@ -2,6 +2,7 @@
namespace League\CLImate\Tests\Util\System;
+use League\CLImate\Util\System\Windows;
use League\CLImate\Tests\TestBase;
use Mockery;
@@ -10,7 +11,7 @@ class WindowsTest extends TestBase
/** @test */
public function it_can_get_the_width()
{
- $system = Mockery::mock('League\CLImate\Util\System\Windows')
+ $system = Mockery::mock(Windows::class)
->makePartial()
->shouldAllowMockingProtectedMethods();
@@ -22,7 +23,7 @@ public function it_can_get_the_width()
/** @test */
public function it_will_return_null_if_width_is_not_numeric()
{
- $system = Mockery::mock('League\CLImate\Util\System\Windows')
+ $system = Mockery::mock(Windows::class)
->makePartial()
->shouldAllowMockingProtectedMethods();
@@ -34,7 +35,7 @@ public function it_will_return_null_if_width_is_not_numeric()
/** @test */
public function it_can_get_the_height()
{
- $system = Mockery::mock('League\CLImate\Util\System\Windows')
+ $system = Mockery::mock(Windows::class)
->makePartial()
->shouldAllowMockingProtectedMethods();
@@ -46,7 +47,7 @@ public function it_can_get_the_height()
/** @test */
public function it_will_return_null_if_height_is_not_numeric()
{
- $system = Mockery::mock('League\CLImate\Util\System\Windows')
+ $system = Mockery::mock(Windows::class)
->makePartial()
->shouldAllowMockingProtectedMethods();
diff --git a/tests/Util/Writer/FileTest.php b/tests/Util/Writer/FileTest.php
index 0bcb54ca..2fee91fe 100644
--- a/tests/Util/Writer/FileTest.php
+++ b/tests/Util/Writer/FileTest.php
@@ -8,6 +8,7 @@
use League\CLImate\Exceptions\RuntimeException;
use League\CLImate\Tests\TestBase;
use League\CLImate\Util\Output;
+use League\CLImate\Util\Writer\File;
use org\bovigo\vfs\vfsStream;
class FileTest extends TestBase
@@ -23,7 +24,7 @@ public function setUp(): void
protected function getFileMock()
{
- return \Mockery::mock('League\CLImate\Util\Writer\File', func_get_args())->makePartial();
+ return \Mockery::mock(File::class, func_get_args())->makePartial();
}
/** @test */