Skip to content

Commit

Permalink
Add test and make sure gitattributes are set.
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Sep 24, 2014
1 parent 26b5cf2 commit 5930a41
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
@@ -0,0 +1,7 @@
# Define the line ending behavior of the different file extensions
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
* text eol=lf

# Declare files that will always have CRLF line endings on checkout.
*.bat eol=crlf
4 changes: 2 additions & 2 deletions src/Shell/Task/I18nTask.php
Expand Up @@ -12,9 +12,9 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Upgrade\Console\Command\Task;
namespace Cake\Upgrade\Shell\Task;

use Cake\Upgrade\Console\Command\Task\BaseTask;
use Cake\Upgrade\Shell\Task\BaseTask;

/**
* I18n Task.
Expand Down
2 changes: 1 addition & 1 deletion src/Shell/Task/StageTask.php
Expand Up @@ -266,7 +266,7 @@ public function change($filePath, $original, $updated) {
}

/**
* Get the source of a file, taking account that there may be incremental diffs
* Get the source of a file, taking into account that there may be incremental diffs
*
* @param string $path
* @return string
Expand Down
50 changes: 50 additions & 0 deletions tests/TestCase/Shell/Task/I18nTaskTest.php
@@ -0,0 +1,50 @@
<?php
namespace Cake\Upgrade\Test\TestCase\Shell\Task;

use Cake\TestSuite\TestCase;
use Cake\Upgrade\Shell\Task\I18nTask;

/**
* UpgradeShellTest
*
*/
class I18nTaskTest extends TestCase {

/**
* Upgrade shell instance
*
* @var mixed
*/
public $sut;

/**
* setUp
*
* Create a mock for all tests to use
*
* @return void
*/
public function setUp() {
parent::setUp();

$io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);

$this->sut = $this->getMock(
'Cake\Upgrade\Shell\Task\I18nTask',
['in', 'out', 'hr', 'err', '_stop'],
[$io]
);
$this->sut->loadTasks();
}

public function testProcess() {
$path = TESTS . 'test_files' . DS;
$result = $this->sut->process($path . 'i18n_before.php');
$this->assertTrue($result);

$result = $this->sut->Stage->source($path . 'i18n_before.php');
$expected = file_get_contents($path . 'i18n_after.php');
$this->assertTextEquals($expected, $result);
}

}
Empty file removed tests/TestCase/Shell/empty
Empty file.
10 changes: 10 additions & 0 deletions tests/test_files/i18n_after.php
@@ -0,0 +1,10 @@
<?php

class Foo {

public function test() {
$x = __("Some {0} text", $y);
$x = __d('Domain', "Some {0} {1} text {2}", $a, $b, $c);
}

}
10 changes: 10 additions & 0 deletions tests/test_files/i18n_before.php
@@ -0,0 +1,10 @@
<?php

class Foo {

public function test() {
$x = __("Some %s text", $y);
$x = __d('Domain', "Some %s %s text %s", $a, $b, $c);
}

}

0 comments on commit 5930a41

Please sign in to comment.