|
|
@@ -16,6 +16,9 @@ namespace Cake\Test\TestCase\Console;
|
|
|
use Cake\Console\HelperRegistry;
|
|
|
use Cake\Core\Plugin;
|
|
|
use Cake\TestSuite\TestCase;
|
|
|
+use TestApp\Command\Helper\CommandHelper;
|
|
|
+use TestApp\Shell\Helper\SimpleHelper;
|
|
|
+use TestPlugin\Shell\Helper\ExampleHelper;
|
|
|
|
|
|
/**
|
|
|
* HelperRegistryTest
|
|
|
@@ -58,14 +61,29 @@ class HelperRegistryTest extends TestCase
|
|
|
public function testLoad()
|
|
|
{
|
|
|
$result = $this->helpers->load('Simple');
|
|
|
- $this->assertInstanceOf('TestApp\Shell\Helper\SimpleHelper', $result);
|
|
|
- $this->assertInstanceOf('TestApp\Shell\Helper\SimpleHelper', $this->helpers->Simple);
|
|
|
+ $this->assertInstanceOf(SimpleHelper::class, $result);
|
|
|
+ $this->assertInstanceOf(SimpleHelper::class, $this->helpers->Simple);
|
|
|
|
|
|
$result = $this->helpers->loaded();
|
|
|
$this->assertEquals(['Simple'], $result, 'loaded() results are wrong.');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * test loading helpers.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testLoadCommandNamespace()
|
|
|
+ {
|
|
|
+ $result = $this->helpers->load('Command');
|
|
|
+ $this->assertInstanceOf(CommandHelper::class, $result);
|
|
|
+ $this->assertInstanceOf(CommandHelper::class, $this->helpers->Command);
|
|
|
+
|
|
|
+ $result = $this->helpers->loaded();
|
|
|
+ $this->assertEquals(['Command'], $result, 'loaded() results are wrong.');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* test triggering callbacks on loaded helpers
|
|
|
*
|
|
|
* @return void
|
|
|
@@ -97,15 +115,15 @@ class HelperRegistryTest extends TestCase
|
|
|
Plugin::load('TestPlugin');
|
|
|
|
|
|
$result = $this->helpers->load('SimpleAliased', ['className' => 'Simple']);
|
|
|
- $this->assertInstanceOf('TestApp\Shell\Helper\SimpleHelper', $result);
|
|
|
- $this->assertInstanceOf('TestApp\Shell\Helper\SimpleHelper', $this->helpers->SimpleAliased);
|
|
|
+ $this->assertInstanceOf(SimpleHelper::class, $result);
|
|
|
+ $this->assertInstanceOf(SimpleHelper::class, $this->helpers->SimpleAliased);
|
|
|
|
|
|
$result = $this->helpers->loaded();
|
|
|
$this->assertEquals(['SimpleAliased'], $result, 'loaded() results are wrong.');
|
|
|
|
|
|
$result = $this->helpers->load('SomeHelper', ['className' => 'TestPlugin.Example']);
|
|
|
- $this->assertInstanceOf('TestPlugin\Shell\Helper\ExampleHelper', $result);
|
|
|
- $this->assertInstanceOf('TestPlugin\Shell\Helper\ExampleHelper', $this->helpers->SomeHelper);
|
|
|
+ $this->assertInstanceOf(ExampleHelper::class, $result);
|
|
|
+ $this->assertInstanceOf(ExampleHelper::class, $this->helpers->SomeHelper);
|
|
|
|
|
|
$result = $this->helpers->loaded();
|
|
|
$this->assertEquals(['SimpleAliased', 'SomeHelper'], $result, 'loaded() results are wrong.');
|