forked from yiisoft/yii2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPjaxTest.php
59 lines (53 loc) · 1.53 KB
/
PjaxTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\widgets;
use yii\data\ArrayDataProvider;
use yii\widgets\ListView;
use yii\widgets\Pjax;
use yiiunit\TestCase;
class PjaxTest extends TestCase
{
public function testGeneratedIdByPjaxWidget()
{
ListView::$counter = 0;
Pjax::$counter = 0;
$nonPjaxWidget1 = new ListView(['dataProvider' => new ArrayDataProvider()]);
ob_start();
$pjax1 = new Pjax();
ob_end_clean();
$nonPjaxWidget2 = new ListView(['dataProvider' => new ArrayDataProvider()]);
ob_start();
$pjax2 = new Pjax();
ob_end_clean();
$this->assertEquals('w0', $nonPjaxWidget1->options['id']);
$this->assertEquals('w1', $nonPjaxWidget2->options['id']);
$this->assertEquals('p0', $pjax1->options['id']);
$this->assertEquals('p1', $pjax2->options['id']);
}
protected function setUp()
{
parent::setUp();
$this->mockWebApplication();
}
/**
* @see https://github.com/yiisoft/yii2/issues/15536
*/
public function testShouldTriggerInitEvent()
{
$initTriggered = false;
ob_start();
$pjax = new Pjax(
[
'on init' => function () use (&$initTriggered) {
$initTriggered = true;
}
]
);
ob_end_clean();
$this->assertTrue($initTriggered);
}
}