Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominus77 committed May 2, 2018
1 parent 70b50e7 commit 79019d4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
7 changes: 4 additions & 3 deletions SocialLikes.php
Expand Up @@ -66,7 +66,7 @@ class SocialLikes extends \yii\base\Widget
public function init()
{
parent::init();
$this->id = $this->id ? $this->id : $this->getId();
$this->id = $this->id ?: $this->getId();
$containerOptions = [
'id' => $this->id,
];
Expand Down Expand Up @@ -150,12 +150,13 @@ protected function registerClientButton($view)
/**
* @param \yii\web\View $view
*/
protected function registerClientOptions($view)
public function registerClientOptions($view)
{
if (!empty($this->clientOptions)) {
$options = Json::encode($this->clientOptions);
$id = $this->containerOptions['id'];
$script = new JsExpression("
var container = document.getElementById('{$this->id}');
var container = document.getElementById('{$id}');
var socialLikes = SocialLikesNext.default;
socialLikes(container, {$options});
");
Expand Down
16 changes: 10 additions & 6 deletions tests/functional/SocialLikesTest.php
Expand Up @@ -19,9 +19,6 @@ public function testGetClientOptions()
$widget = new SocialLikes([
'theme' => \dominus77\sociallikesnext\SocialLikes::THEME_FLAT,
'title' => true,
'clientOptions' => [
'options' => true,
],
'containerOptions' => [
'class' => 'social-likes_vertical',
'data-url' => 'http://landscapists.info/',
Expand All @@ -32,9 +29,6 @@ public function testGetClientOptions()
$clientOptions = [
'theme' => 'flat',
'title' => true,
'clientOptions' => [
'options' => true,
],
'containerOptions' => [
'class' => 'social-likes_vertical',
'data-url' => 'http://landscapists.info/',
Expand Down Expand Up @@ -78,4 +72,14 @@ public function testRun()
]);
$this->assertEquals($widget->run(), null);
}

public function testRegisterClientOptions()
{
$view = \Yii::$app->getView();
$widget = new SocialLikes();
$widget->clientOptions = [
'title' => 'GitHub'
];
$this->assertEquals($widget->registerClientOptions($view), null);
}
}
4 changes: 2 additions & 2 deletions tests/functional/TestCase.php
Expand Up @@ -101,8 +101,8 @@ protected function mockWebApplication($config = [], $appClass = '\yii\web\Applic
*/
protected function getVendorPath()
{
//return dirname(dirname(dirname(dirname(__DIR__)))) . '/yii2-developer.loc/vendor';
return dirname(dirname(__DIR__)) . '/vendor';
return dirname(dirname(dirname(dirname(__DIR__)))) . '/yii2-developer.loc/vendor';
//return dirname(dirname(__DIR__)) . '/vendor';
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/bootstrap.php
Expand Up @@ -5,9 +5,9 @@
define('YII_DEBUG', true);
$_SERVER['SCRIPT_NAME'] = '/' . __DIR__;
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
//require_once(__DIR__ . '/../../../../yii2-developer.loc/vendor/autoload.php');
//require_once(__DIR__ . '/../../../../yii2-developer.loc/vendor/yiisoft/yii2/Yii.php');
require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require_once(__DIR__ . '/../../../../yii2-developer.loc/vendor/autoload.php');
require_once(__DIR__ . '/../../../../yii2-developer.loc/vendor/yiisoft/yii2/Yii.php');
//require_once(__DIR__ . '/../../vendor/autoload.php');
//require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
Yii::setAlias('@tests', __DIR__);
require_once(__DIR__ . '/TestCase.php');
1 change: 0 additions & 1 deletion tests/functional/views/layouts/rawlayout.php
Expand Up @@ -3,4 +3,3 @@
?>

<?php $this->beginPage(); ?>1<?php $this->head(); ?>2<?php $this->beginBody(); ?>3<?php $this->endBody(); ?>4<?php $this->endPage(); ?>

0 comments on commit 79019d4

Please sign in to comment.