Browse Source

Fix shell.

mscherer 6 years ago
parent
commit
92701187d5
4 changed files with 43 additions and 9 deletions
  1. 1 0
      .gitignore
  2. 1 1
      src/Shell/InflectShell.php
  3. 27 8
      tests/TestCase/Shell/InflectShellTest.php
  4. 14 0
      tests/bootstrap.php

+ 1 - 0
.gitignore

@@ -4,3 +4,4 @@
 /tmp/
 /composer.phar
 /.idea
+.phpunit.result.cache

+ 1 - 1
src/Shell/InflectShell.php

@@ -3,7 +3,7 @@
 namespace Tools\Shell;
 
 use Cake\Console\Shell;
-use Cake\Utility\Inflector;
+use Shim\Utility\Inflector;
 
 /**
  * Inflect Shell

+ 27 - 8
tests/TestCase/Shell/InflectShellTest.php

@@ -14,7 +14,17 @@ class InflectShellTest extends TestCase {
 	/**
 	 * @var \Tools\Shell\InflectShell
 	 */
-	public $Shell;
+	protected $Shell;
+
+	/**
+	 * @var \Tools\TestSuite\ConsoleOutput
+	 */
+	protected $out;
+
+	/**
+	 * @var \Tools\TestSuite\ConsoleOutput
+	 */
+	protected $err;
 
 	/**
 	 * @return void
@@ -41,8 +51,6 @@ class InflectShellTest extends TestCase {
 	}
 
 	/**
-	 * test that the startup method supresses the shell header
-	 *
 	 * @return void
 	 */
 	public function testMain() {
@@ -52,27 +60,38 @@ class InflectShellTest extends TestCase {
 		$this->Shell->runCommand(['pluralize']);
 		$output = $this->out->output();
 		$expected = 'FooBars';
-		$this->assertContains($expected, $output);
+		$this->assertStringContainsString($expected, $output);
 
 		$this->Shell->runCommand(['underscore']);
 		$output = $this->out->output();
 		$expected = 'foo_bar';
-		$this->assertContains($expected, $output);
+		$this->assertStringContainsString($expected, $output);
 
 		$this->Shell->runCommand(['dasherize']);
 		$output = $this->out->output();
 		$expected = 'foo-bar';
-		$this->assertContains($expected, $output);
+		$this->assertStringContainsString($expected, $output);
 
 		$this->Shell->runCommand(['slug']);
 		$output = $this->out->output();
 		$expected = 'foo-bar';
-		$this->assertContains($expected, $output);
+		$this->assertStringContainsString($expected, $output);
 
 		$this->Shell->runCommand(['tableize']);
 		$output = $this->out->output();
 		$expected = 'foo_bar';
-		$this->assertContains($expected, $output);
+		$this->assertStringContainsString($expected, $output);
+	}
+
+	/**
+	 * @return void
+	 */
+	public function testMainAll() {
+		$this->Shell->runCommand(['all', 'Foo Bar']);
+		$output = $this->out->output();
+
+		$this->assertStringContainsString('Pluralized form', $output);
+		$this->assertStringContainsString('Slugged-form', $output);
 	}
 
 }

+ 14 - 0
tests/bootstrap.php

@@ -1,5 +1,7 @@
 <?php
 
+use Cake\Datasource\ConnectionManager;
+
 if (!defined('DS')) {
 	define('DS', DIRECTORY_SEPARATOR);
 }
@@ -75,6 +77,18 @@ Cake\Cache\Cache::setConfig($cache);
 //Cake\Core\Plugin::load('Tools', ['path' => ROOT . DS, 'bootstrap' => true]);
 (new Cake\Core\PluginCollection)->add(new Tools\Plugin(['bootstrap' => true]));
 
+if (getenv('db_dsn')) {
+	ConnectionManager::setConfig('test', [
+		'className' => 'Cake\Database\Connection',
+		'url' => getenv('db_dsn'),
+		'timezone' => 'UTC',
+		'quoteIdentifiers' => true,
+		'cacheMetadata' => true,
+	]);
+
+	return;
+}
+
 // Ensure default test connection is defined
 if (!getenv('db_class')) {
 	putenv('db_class=Cake\Database\Driver\Sqlite');