Commit 2a19b3ca by Carsten Brandt

fixed whitespace in tests

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