mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
fixed whitespace in tests
This commit is contained in:
@ -24,4 +24,4 @@ class ExposedSecurity extends Security
|
||||
{
|
||||
return parent::pbkdf2($algo, $password, $salt, $iterations, $length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,4 +82,4 @@ class POMessageControllerTest extends BaseMessageControllerTest
|
||||
$gettext = new GettextPoFile();
|
||||
return $gettext->load($messageFilePath, $category);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -24,4 +24,4 @@ trait StdOutBufferControllerTrait
|
||||
$this->stdOutBuffer = '';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ use yii\web\AssetManager;
|
||||
|
||||
/**
|
||||
* @author Nelson J Morais <njmorais@gmail.com>
|
||||
*
|
||||
*
|
||||
* @group widgets
|
||||
*/
|
||||
class ActiveFieldTest extends \yiiunit\TestCase
|
||||
@ -20,30 +20,30 @@ class ActiveFieldTest extends \yiiunit\TestCase
|
||||
private $helperModel;
|
||||
private $helperForm;
|
||||
private $attributeName = 'attributeName';
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
Yii::setAlias('@testWeb', '/');
|
||||
Yii::setAlias('@testWebRoot', '@yiiunit/data/web');
|
||||
|
||||
|
||||
$this->helperModel = new DynamicModel(['attributeName']);
|
||||
ob_start();
|
||||
$this->helperForm = new ActiveForm(['action' => '/something']);
|
||||
ob_end_clean();
|
||||
|
||||
|
||||
$this->activeField = new ActiveFieldExtend(true);
|
||||
$this->activeField->form = $this->helperForm;
|
||||
$this->activeField->form->setView($this->getView());
|
||||
$this->activeField->model = $this->helperModel;
|
||||
$this->activeField->attribute = $this->attributeName;
|
||||
}
|
||||
|
||||
|
||||
public function testRenderNoContent()
|
||||
{
|
||||
$expectedValue = <<<EOD
|
||||
@ -54,11 +54,11 @@ class ActiveFieldTest extends \yiiunit\TestCase
|
||||
<div class="help-block"></div>
|
||||
</div>
|
||||
EOD;
|
||||
|
||||
|
||||
$actualValue = $this->activeField->render();
|
||||
$this->assertEquals($expectedValue, $actualValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @todo discuss|review Expected HTML shouldn't be wrapped only by the $content?
|
||||
*/
|
||||
@ -80,101 +80,101 @@ EOD;
|
||||
</div> </div>
|
||||
</div>
|
||||
EOD;
|
||||
|
||||
|
||||
$actualValue = $this->activeField->render($content);
|
||||
$this->assertEquals($expectedValue, $actualValue);
|
||||
}
|
||||
|
||||
|
||||
public function testBeginHasErros()
|
||||
{
|
||||
$this->helperModel->addError($this->attributeName, "Error Message");
|
||||
|
||||
|
||||
$expectedValue = '<div class="form-group field-dynamicmodel-attributename has-error">';
|
||||
$actualValue = $this->activeField->begin();
|
||||
|
||||
|
||||
$this->assertEquals($expectedValue, $actualValue);
|
||||
}
|
||||
|
||||
|
||||
public function testBeginAttributeIsRequered()
|
||||
{
|
||||
$this->helperModel->addRule($this->attributeName, 'required');
|
||||
|
||||
|
||||
$expectedValue = '<div class="form-group field-dynamicmodel-attributename required">';
|
||||
$actualValue = $this->activeField->begin();
|
||||
|
||||
$this->assertEquals($expectedValue, $actualValue);
|
||||
|
||||
$this->assertEquals($expectedValue, $actualValue);
|
||||
}
|
||||
|
||||
|
||||
public function testBeginHasErrorAndRequired()
|
||||
{
|
||||
$this->helperModel->addError($this->attributeName, "Error Message");
|
||||
$this->helperModel->addRule($this->attributeName, 'required');
|
||||
|
||||
|
||||
$expectedValue = '<div class="form-group field-dynamicmodel-attributename required has-error">';
|
||||
$actualValue = $this->activeField->begin();
|
||||
|
||||
|
||||
$this->assertEquals($expectedValue, $actualValue);
|
||||
}
|
||||
|
||||
|
||||
public function testEnd()
|
||||
{
|
||||
$expectedValue = '</div>';
|
||||
$actualValue = $this->activeField->end();
|
||||
|
||||
|
||||
$this->assertEquals($expectedValue, $actualValue);
|
||||
|
||||
|
||||
// other tag
|
||||
$expectedValue = "</article>";
|
||||
$this->activeField->options['tag'] = 'article';
|
||||
$actualValue = $this->activeField->end();
|
||||
|
||||
|
||||
$this->assertTrue($actualValue === $expectedValue);
|
||||
}
|
||||
|
||||
|
||||
public function testLabel()
|
||||
{
|
||||
$expectedValue = '<label class="control-label" for="dynamicmodel-attributename">Attribute Name</label>';
|
||||
$this->activeField->label();
|
||||
|
||||
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{label}']);
|
||||
|
||||
|
||||
// label = false
|
||||
$expectedValue = '';
|
||||
$this->activeField->label(false);
|
||||
|
||||
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{label}']);
|
||||
|
||||
|
||||
// $label = 'Label Name'
|
||||
$label = 'Label Name';
|
||||
$expectedValue = <<<EOT
|
||||
<label class="control-label" for="dynamicmodel-attributename">{$label}</label>
|
||||
EOT;
|
||||
$this->activeField->label($label);
|
||||
|
||||
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{label}']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testError()
|
||||
{
|
||||
$expectedValue = '<label class="control-label" for="dynamicmodel-attributename">Attribute Name</label>';
|
||||
$this->activeField->label();
|
||||
|
||||
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{label}']);
|
||||
|
||||
|
||||
// label = false
|
||||
$expectedValue = '';
|
||||
$this->activeField->label(false);
|
||||
|
||||
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{label}']);
|
||||
|
||||
|
||||
// $label = 'Label Name'
|
||||
$label = 'Label Name';
|
||||
$expectedValue = <<<EOT
|
||||
<label class="control-label" for="dynamicmodel-attributename">{$label}</label>
|
||||
EOT;
|
||||
$this->activeField->label($label);
|
||||
|
||||
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{label}']);
|
||||
}
|
||||
|
||||
@ -182,28 +182,28 @@ EOT;
|
||||
{
|
||||
$expectedValue = '<div class="hint-block">Hint Content</div>';
|
||||
$this->activeField->hint('Hint Content');
|
||||
|
||||
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{hint}']);
|
||||
}
|
||||
|
||||
|
||||
public function testInput()
|
||||
{
|
||||
$expectedValue = <<<EOD
|
||||
<input type="password" id="dynamicmodel-attributename" class="form-control" name="DynamicModel[attributeName]">
|
||||
EOD;
|
||||
$this->activeField->input("password");
|
||||
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{input}']);
|
||||
|
||||
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{input}']);
|
||||
|
||||
// with options
|
||||
$expectedValue = <<<EOD
|
||||
<input type="password" id="dynamicmodel-attributename" class="form-control" name="DynamicModel[attributeName]" weird="value">
|
||||
EOD;
|
||||
$this->activeField->input("password", ['weird' => 'value']);
|
||||
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{input}']);
|
||||
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{input}']);
|
||||
}
|
||||
|
||||
|
||||
public function testTextInput()
|
||||
{
|
||||
$expectedValue = <<<EOD
|
||||
@ -212,7 +212,7 @@ EOD;
|
||||
$this->activeField->textInput();
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{input}']);
|
||||
}
|
||||
|
||||
|
||||
public function testHiddenInput()
|
||||
{
|
||||
$expectedValue = <<<EOD
|
||||
@ -221,7 +221,7 @@ EOD;
|
||||
$this->activeField->hiddenInput();
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{input}']);
|
||||
}
|
||||
|
||||
|
||||
public function testListBox()
|
||||
{
|
||||
$expectedValue = <<<EOD
|
||||
@ -233,36 +233,36 @@ EOD;
|
||||
$this->activeField->listBox(["1" => "Item One", "2" => "Item 2"]);
|
||||
$this->assertEquals($expectedValue, $this->activeField->parts['{input}']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function testGetClientOptionsReturnEmpty()
|
||||
{
|
||||
// setup: we want the real deal here!
|
||||
$this->activeField->setClientOptionsEmpty(false);
|
||||
|
||||
|
||||
// expected empty
|
||||
$actualValue = $this->activeField->getClientOptions();
|
||||
$this->assertTrue(empty($actualValue) === true);
|
||||
$this->assertTrue(empty($actualValue) === true);
|
||||
}
|
||||
|
||||
|
||||
public function testGetClientOptionsWithActiveAttributeInScenario()
|
||||
{
|
||||
$this->activeField->setClientOptionsEmpty(false);
|
||||
|
||||
|
||||
$this->activeField->model->addRule($this->attributeName, 'yiiunit\framework\widgets\TestValidator');
|
||||
$this->activeField->form->enableClientValidation = false;
|
||||
|
||||
|
||||
// expected empty
|
||||
$actualValue = $this->activeField->getClientOptions();
|
||||
$this->assertTrue(empty($actualValue) === true);
|
||||
|
||||
$this->assertTrue(empty($actualValue) === true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testGetClientOptionsClientValidation()
|
||||
{
|
||||
$this->activeField->setClientOptionsEmpty(false);
|
||||
|
||||
|
||||
$this->activeField->model->addRule($this->attributeName, 'yiiunit\framework\widgets\TestValidator');
|
||||
$this->activeField->enableClientValidation = true;
|
||||
$actualValue = $this->activeField->getClientOptions();
|
||||
@ -286,7 +286,7 @@ EOD;
|
||||
$this->assertTrue($expectedValidateOnChange === $actualValue['validateOnChange']);
|
||||
$this->assertTrue($expectedValidateOnBlur === $actualValue['validateOnBlur']);
|
||||
$this->assertTrue($expectedValidateOnType === $actualValue['validateOnType']);
|
||||
$this->assertTrue($expectedValidationDelay === $actualValue['validationDelay']);
|
||||
$this->assertTrue($expectedValidationDelay === $actualValue['validationDelay']);
|
||||
$this->assertTrue($expectedEnableAjaxValidation === $actualValue['enableAjaxValidation']);
|
||||
}
|
||||
|
||||
@ -295,18 +295,18 @@ EOD;
|
||||
$this->activeField->setClientOptionsEmpty(false);
|
||||
$this->activeField->enableAjaxValidation = true;
|
||||
$this->activeField->model->addRule($this->attributeName, 'yiiunit\framework\widgets\TestValidator');
|
||||
|
||||
|
||||
foreach($this->activeField->model->validators as $validator) {
|
||||
$validator->whenClient = "function (attribute, value) { return 'yii2' == 'yii2'; }"; // js
|
||||
$validator->whenClient = "function (attribute, value) { return 'yii2' == 'yii2'; }"; // js
|
||||
}
|
||||
|
||||
|
||||
$actualValue = $this->activeField->getClientOptions();
|
||||
$expectedJsExpression = "function (attribute, value, messages, deferred) {if ((function (attribute, value) "
|
||||
. "{ return 'yii2' == 'yii2'; })(attribute, value)) { return true; }}";
|
||||
|
||||
|
||||
$this->assertEquals($expectedJsExpression, $actualValue['validate']->expression);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper methods
|
||||
*/
|
||||
@ -320,7 +320,7 @@ EOD;
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -329,17 +329,17 @@ EOD;
|
||||
class ActiveFieldExtend extends ActiveField
|
||||
{
|
||||
private $getClientOptionsEmpty;
|
||||
|
||||
|
||||
public function __construct($getClientOptionsEmpty = true)
|
||||
{
|
||||
$this->getClientOptionsEmpty = $getClientOptionsEmpty;
|
||||
}
|
||||
|
||||
|
||||
public function setClientOptionsEmpty($value)
|
||||
{
|
||||
$this->getClientOptionsEmpty = (bool) $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Useful to test other methods from ActiveField, that call ActiveField::getClientOptions()
|
||||
* but it's return value is not relevant for the test being run.
|
||||
@ -352,12 +352,12 @@ class ActiveFieldExtend extends ActiveField
|
||||
|
||||
class TestValidator extends \yii\validators\Validator
|
||||
{
|
||||
|
||||
|
||||
public function clientValidateAttribute($object, $attribute, $view)
|
||||
{
|
||||
return "return true;";
|
||||
}
|
||||
|
||||
|
||||
public function setWhenClient($js)
|
||||
{
|
||||
$this->whenClient = $js;
|
||||
|
||||
@ -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-<br>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-<br>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-<br>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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user