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