Commit 2a19b3ca by Carsten Brandt

fixed whitespace in tests

parent 5cb2ce49
...@@ -24,4 +24,4 @@ class ExposedSecurity extends Security ...@@ -24,4 +24,4 @@ class ExposedSecurity extends Security
{ {
return parent::pbkdf2($algo, $password, $salt, $iterations, $length); return parent::pbkdf2($algo, $password, $salt, $iterations, $length);
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -30,7 +30,7 @@ class CacheControllerTest extends TestCase ...@@ -30,7 +30,7 @@ class CacheControllerTest extends TestCase
'class' => 'yiiunit\framework\console\controllers\SilencedCacheController', 'class' => 'yiiunit\framework\console\controllers\SilencedCacheController',
'interactive' => false, 'interactive' => false,
],[null, null]); //id and module are null ],[null, null]); //id and module are null
$databases = self::getParam('databases'); $databases = self::getParam('databases');
$config = $databases[$this->driverName]; $config = $databases[$this->driverName];
$pdoDriver = 'pdo_' . $this->driverName; $pdoDriver = 'pdo_' . $this->driverName;
...@@ -38,7 +38,7 @@ class CacheControllerTest extends TestCase ...@@ -38,7 +38,7 @@ class CacheControllerTest extends TestCase
if (!extension_loaded('pdo') || !extension_loaded($pdoDriver)) { if (!extension_loaded('pdo') || !extension_loaded($pdoDriver)) {
$this->markTestSkipped('pdo and ' . $pdoDriver . ' extensions are required.'); $this->markTestSkipped('pdo and ' . $pdoDriver . ' extensions are required.');
} }
$this->mockApplication([ $this->mockApplication([
'components' => [ 'components' => [
...@@ -55,7 +55,7 @@ class CacheControllerTest extends TestCase ...@@ -55,7 +55,7 @@ class CacheControllerTest extends TestCase
], ],
], ],
]); ]);
if(isset($config['fixture'])) { if(isset($config['fixture'])) {
Yii::$app->db->open(); Yii::$app->db->open();
$lines = explode(';', file_get_contents($config['fixture'])); $lines = explode(';', file_get_contents($config['fixture']));
...@@ -79,7 +79,7 @@ class CacheControllerTest extends TestCase ...@@ -79,7 +79,7 @@ class CacheControllerTest extends TestCase
$this->assertFalse(Yii::$app->firstCache->get('secondKey'),'first cache data should be flushed'); $this->assertFalse(Yii::$app->firstCache->get('secondKey'),'first cache data should be flushed');
$this->assertEquals('thirdValue', Yii::$app->secondCache->get('thirdKey'), 'second cache data should not be flushed'); $this->assertEquals('thirdValue', Yii::$app->secondCache->get('thirdKey'), 'second cache data should not be flushed');
} }
public function testClearSchema() public function testClearSchema()
{ {
$schema = Yii::$app->db->schema; $schema = Yii::$app->db->schema;
......
...@@ -255,4 +255,4 @@ CODE; ...@@ -255,4 +255,4 @@ CODE;
$this->assertMigrationHistory(['base', 'test1']); $this->assertMigrationHistory(['base', 'test1']);
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -82,4 +82,4 @@ class POMessageControllerTest extends BaseMessageControllerTest ...@@ -82,4 +82,4 @@ class POMessageControllerTest extends BaseMessageControllerTest
$gettext = new GettextPoFile(); $gettext = new GettextPoFile();
return $gettext->load($messageFilePath, $category); return $gettext->load($messageFilePath, $category);
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -24,4 +24,4 @@ trait StdOutBufferControllerTrait ...@@ -24,4 +24,4 @@ trait StdOutBufferControllerTrait
$this->stdOutBuffer = ''; $this->stdOutBuffer = '';
return $result; return $result;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -99,25 +99,25 @@ class StringHelperTest extends TestCase ...@@ -99,25 +99,25 @@ class StringHelperTest extends TestCase
$this->assertEquals('foo', StringHelper::basename('/bar/foo/')); $this->assertEquals('foo', StringHelper::basename('/bar/foo/'));
$this->assertEquals('foo', StringHelper::basename('\\bar\\foo\\')); $this->assertEquals('foo', StringHelper::basename('\\bar\\foo\\'));
} }
public function testTruncate() public function testTruncate()
{ {
$this->assertEquals('привет, я multibyte...', StringHelper::truncate('привет, я multibyte строка!', 20)); $this->assertEquals('привет, я multibyte...', StringHelper::truncate('привет, я multibyte строка!', 20));
$this->assertEquals('Не трогаем строку', StringHelper::truncate('Не трогаем строку', 20)); $this->assertEquals('Не трогаем строку', StringHelper::truncate('Не трогаем строку', 20));
$this->assertEquals('исполь!!!', StringHelper::truncate('используем восклицательные знаки', 6, '!!!')); $this->assertEquals('исполь!!!', StringHelper::truncate('используем восклицательные знаки', 6, '!!!'));
// With Html // With Html
$this->assertEquals('<span>This is a test </span>...', StringHelper::truncate('<span>This is a test sentance</span>', 14, '...', null, true)); $this->assertEquals('<span>This is a test </span>...', StringHelper::truncate('<span>This is a test sentance</span>', 14, '...', null, true));
$this->assertEquals('<span><img src="image.png" />This is a test </span>...', StringHelper::truncate('<span><img src="image.png" />This is a test sentance</span>', 14, '...', null, true)); $this->assertEquals('<span><img src="image.png" />This is a test </span>...', StringHelper::truncate('<span><img src="image.png" />This is a test sentance</span>', 14, '...', null, true));
} }
public function testTruncateWords() public function testTruncateWords()
{ {
$this->assertEquals('это тестовая multibyte строка', StringHelper::truncateWords('это тестовая multibyte строка', 5)); $this->assertEquals('это тестовая multibyte строка', StringHelper::truncateWords('это тестовая multibyte строка', 5));
$this->assertEquals('это тестовая multibyte...', StringHelper::truncateWords('это тестовая multibyte строка', 3)); $this->assertEquals('это тестовая multibyte...', StringHelper::truncateWords('это тестовая multibyte строка', 3));
$this->assertEquals('это тестовая multibyte!!!', StringHelper::truncateWords('это тестовая multibyte строка', 3, '!!!')); $this->assertEquals('это тестовая multibyte!!!', StringHelper::truncateWords('это тестовая multibyte строка', 3, '!!!'));
$this->assertEquals('это строка с неожиданными...', StringHelper::truncateWords('это строка с неожиданными пробелами', 4)); $this->assertEquals('это строка с неожиданными...', StringHelper::truncateWords('это строка с неожиданными пробелами', 4));
// With Html // With Html
$this->assertEquals('<span>This is a test</span>...', StringHelper::truncateWords('<span>This is a test sentance</span>', 4, '...', true)); $this->assertEquals('<span>This is a test</span>...', StringHelper::truncateWords('<span>This is a test sentance</span>', 4, '...', true));
$this->assertEquals('<span><img src="image.png" />This is a test</span>...', StringHelper::truncateWords('<span><img src="image.png" />This is a test sentance</span>', 4, '...', true)); $this->assertEquals('<span><img src="image.png" />This is a test</span>...', StringHelper::truncateWords('<span><img src="image.png" />This is a test sentance</span>', 4, '...', true));
......
...@@ -53,7 +53,7 @@ class I18NTest extends TestCase ...@@ -53,7 +53,7 @@ class I18NTest extends TestCase
// fallback to just langauge code with present exact match // fallback to just langauge code with present exact match
$this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE'));
} }
public function testDefaultSource() public function testDefaultSource()
{ {
$i18n = new I18N([ $i18n = new I18N([
......
...@@ -15,7 +15,7 @@ class ArrayFixtureTest extends TestCase ...@@ -15,7 +15,7 @@ class ArrayFixtureTest extends TestCase
{ {
/** /**
* @var \yii\test\ArrayFixture * @var \yii\test\ArrayFixture
*/ */
private $_fixture; private $_fixture;
......
...@@ -7,82 +7,82 @@ use yii\widgets\Breadcrumbs; ...@@ -7,82 +7,82 @@ use yii\widgets\Breadcrumbs;
/** /**
* @author Nelson J Morais <njmorais@gmail.com> * @author Nelson J Morais <njmorais@gmail.com>
* *
* @group widgets * @group widgets
*/ */
class BreadcrumbsTest extends \yiiunit\TestCase class BreadcrumbsTest extends \yiiunit\TestCase
{ {
private $breadcrumbs; private $breadcrumbs;
public function setUp() public function setUp()
{ {
// dirty way to have Request object not throwing exception when running testHomeLinkNull() // dirty way to have Request object not throwing exception when running testHomeLinkNull()
$_SERVER['SCRIPT_FILENAME'] = "/index.php"; $_SERVER['SCRIPT_FILENAME'] = "/index.php";
$_SERVER['SCRIPT_NAME'] = "/index.php"; $_SERVER['SCRIPT_NAME'] = "/index.php";
$this->mockWebApplication(); $this->mockWebApplication();
$this->breadcrumbs = new Breadcrumbs(); $this->breadcrumbs = new Breadcrumbs();
} }
public function testHomeLinkNull() public function testHomeLinkNull()
{ {
$this->breadcrumbs->homeLink = null; $this->breadcrumbs->homeLink = null;
$this->breadcrumbs->links = ['label' => 'My Home Page', 'url' => 'http://my.example.com/yii2/link/page']; $this->breadcrumbs->links = ['label' => 'My Home Page', 'url' => 'http://my.example.com/yii2/link/page'];
$expectedHtml = "<ul class=\"breadcrumb\"><li><a href=\"/index.php\">Home</a></li>\n" $expectedHtml = "<ul class=\"breadcrumb\"><li><a href=\"/index.php\">Home</a></li>\n"
. "<li class=\"active\">My Home Page</li>\n" . "<li class=\"active\">My Home Page</li>\n"
. "<li class=\"active\">http://my.example.com/yii2/link/page</li>\n" . "<li class=\"active\">http://my.example.com/yii2/link/page</li>\n"
. "</ul>"; . "</ul>";
ob_start(); ob_start();
$this->breadcrumbs->run(); $this->breadcrumbs->run();
$actualHtml = ob_get_contents(); $actualHtml = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertEquals($expectedHtml, $actualHtml); $this->assertEquals($expectedHtml, $actualHtml);
} }
public function testEmptyLinks() public function testEmptyLinks()
{ {
$this->assertNull($this->breadcrumbs->run()); $this->assertNull($this->breadcrumbs->run());
} }
public function testHomeLinkFalse() public function testHomeLinkFalse()
{ {
$this->breadcrumbs->homeLink = false; $this->breadcrumbs->homeLink = false;
$this->breadcrumbs->links = ['label' => 'My Home Page', 'url' => 'http://my.example.com/yii2/link/page']; $this->breadcrumbs->links = ['label' => 'My Home Page', 'url' => 'http://my.example.com/yii2/link/page'];
$expectedHtml = "<ul class=\"breadcrumb\"><li class=\"active\">My Home Page</li>\n" $expectedHtml = "<ul class=\"breadcrumb\"><li class=\"active\">My Home Page</li>\n"
. "<li class=\"active\">http://my.example.com/yii2/link/page</li>\n" . "<li class=\"active\">http://my.example.com/yii2/link/page</li>\n"
. "</ul>"; . "</ul>";
ob_start(); ob_start();
$this->breadcrumbs->run(); $this->breadcrumbs->run();
$actualHtml = ob_get_contents(); $actualHtml = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertEquals($expectedHtml, $actualHtml); $this->assertEquals($expectedHtml, $actualHtml);
} }
public function testHomeLink() public function testHomeLink()
{ {
$this->breadcrumbs->homeLink = ['label' => 'home-link']; $this->breadcrumbs->homeLink = ['label' => 'home-link'];
$this->breadcrumbs->links = ['label' => 'My Home Page', 'url' => 'http://my.example.com/yii2/link/page']; $this->breadcrumbs->links = ['label' => 'My Home Page', 'url' => 'http://my.example.com/yii2/link/page'];
$expectedHtml = "<ul class=\"breadcrumb\"><li>home-link</li>\n" $expectedHtml = "<ul class=\"breadcrumb\"><li>home-link</li>\n"
. "<li class=\"active\">My Home Page</li>\n" . "<li class=\"active\">My Home Page</li>\n"
. "<li class=\"active\">http://my.example.com/yii2/link/page</li>\n" . "<li class=\"active\">http://my.example.com/yii2/link/page</li>\n"
. "</ul>"; . "</ul>";
ob_start(); ob_start();
$this->breadcrumbs->run(); $this->breadcrumbs->run();
$actualHtml = ob_get_contents(); $actualHtml = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertEquals($expectedHtml, $actualHtml); $this->assertEquals($expectedHtml, $actualHtml);
} }
public function testRenderItemException() public function testRenderItemException()
{ {
$link = ['url' => 'http://localhost/yii2']; $link = ['url' => 'http://localhost/yii2'];
...@@ -90,48 +90,48 @@ class BreadcrumbsTest extends \yiiunit\TestCase ...@@ -90,48 +90,48 @@ class BreadcrumbsTest extends \yiiunit\TestCase
$this->setExpectedException('yii\base\InvalidConfigException'); $this->setExpectedException('yii\base\InvalidConfigException');
$method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate); $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate);
} }
public function testRenderItemLabelOnly() public function testRenderItemLabelOnly()
{ {
$link = ['label' => 'My-<br>Test-Label']; $link = ['label' => 'My-<br>Test-Label'];
$method = $this->reflectMethod(); $method = $this->reflectMethod();
$encodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate); $encodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate);
$this->assertEquals("<li>My-&lt;br&gt;Test-Label</li>\n", $encodedValue); $this->assertEquals("<li>My-&lt;br&gt;Test-Label</li>\n", $encodedValue);
//without encodeLabels //without encodeLabels
$this->breadcrumbs->encodeLabels = false; $this->breadcrumbs->encodeLabels = false;
$unencodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate); $unencodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate);
$this->assertEquals("<li>My-<br>Test-Label</li>\n", $unencodedValue); $this->assertEquals("<li>My-<br>Test-Label</li>\n", $unencodedValue);
} }
public function testRenderItemWithLabelAndUrl() public function testRenderItemWithLabelAndUrl()
{ {
$link = ['label' => 'My-<br>Test-Label', 'url' => 'http://localhost/yii2']; $link = ['label' => 'My-<br>Test-Label', 'url' => 'http://localhost/yii2'];
$method = $this->reflectMethod(); $method = $this->reflectMethod();
$encodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate); $encodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate);
$this->assertEquals("<li><a href=\"http://localhost/yii2\">My-&lt;br&gt;Test-Label</a></li>\n", $encodedValue); $this->assertEquals("<li><a href=\"http://localhost/yii2\">My-&lt;br&gt;Test-Label</a></li>\n", $encodedValue);
// without encodeLabels // without encodeLabels
$this->breadcrumbs->encodeLabels = false; $this->breadcrumbs->encodeLabels = false;
$unencodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate); $unencodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate);
$this->assertEquals("<li><a href=\"http://localhost/yii2\">My-<br>Test-Label</a></li>\n", $unencodedValue); $this->assertEquals("<li><a href=\"http://localhost/yii2\">My-<br>Test-Label</a></li>\n", $unencodedValue);
} }
public function testRenderItemTemplate() public function testRenderItemTemplate()
{ {
$link = ['label' => 'My-<br>Test-Label', 'url' => 'http://localhost/yii2', 'template' => "<td>{link}</td>\n"]; $link = ['label' => 'My-<br>Test-Label', 'url' => 'http://localhost/yii2', 'template' => "<td>{link}</td>\n"];
$method = $this->reflectMethod(); $method = $this->reflectMethod();
$encodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate); $encodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate);
$this->assertEquals("<td><a href=\"http://localhost/yii2\">My-&lt;br&gt;Test-Label</a></td>\n", $encodedValue); $this->assertEquals("<td><a href=\"http://localhost/yii2\">My-&lt;br&gt;Test-Label</a></td>\n", $encodedValue);
// without encodeLabels // without encodeLabels
$this->breadcrumbs->encodeLabels = false; $this->breadcrumbs->encodeLabels = false;
$unencodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate); $unencodedValue = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate);
$this->assertEquals("<td><a href=\"http://localhost/yii2\">My-<br>Test-Label</a></td>\n", $unencodedValue); $this->assertEquals("<td><a href=\"http://localhost/yii2\">My-<br>Test-Label</a></td>\n", $unencodedValue);
} }
public function testExtraOptions() public function testExtraOptions()
...@@ -145,7 +145,7 @@ class BreadcrumbsTest extends \yiiunit\TestCase ...@@ -145,7 +145,7 @@ class BreadcrumbsTest extends \yiiunit\TestCase
$result = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate); $result = $method->invoke($this->breadcrumbs, $link, $this->breadcrumbs->itemTemplate);
$this->assertEquals('<li><a class="external" href="http://example.com">demo</a></li>' . "\n", $result); $this->assertEquals('<li><a class="external" href="http://example.com">demo</a></li>' . "\n", $result);
} }
/** /**
* Helper methods * Helper methods
*/ */
...@@ -153,7 +153,7 @@ class BreadcrumbsTest extends \yiiunit\TestCase ...@@ -153,7 +153,7 @@ class BreadcrumbsTest extends \yiiunit\TestCase
{ {
$value = new \ReflectionMethod($class, $method); $value = new \ReflectionMethod($class, $method);
$value->setAccessible(true); $value->setAccessible(true);
return $value; return $value;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment