Skip to content

Commit 19438fa

Browse files
committed
Add test for component initial config
1 parent 294604f commit 19438fa

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"autoload-dev": {
3232
"psr-4": {
33+
"BryanCrowe\\ApiPagination\\": "src",
3334
"BryanCrowe\\ApiPagination\\Test\\": "tests"
3435
}
3536
},

tests/ApiPaginationComponentTest.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
use BryanCrowe\ApiPagination\Controller\Component\ApiPaginationComponent;
55
use Cake\Controller\ComponentRegistry;
66
use Cake\Controller\Controller;
7+
use Cake\Core\Plugin;
78
use Cake\Network\Request;
89
use Cake\Network\Response;
910
use Cake\TestSuite\TestCase;
11+
use PHPUnit_Framework_Assert;
12+
1013

1114
/**
1215
* ApiPaginationComponentTest class
1316
*/
1417
class ApiPaginationComponentTest extends TestCase
1518
{
16-
public $component = null;
17-
public $controller = null;
18-
1919
/**
2020
* setUp method
2121
*
@@ -24,12 +24,6 @@ class ApiPaginationComponentTest extends TestCase
2424
public function setUp()
2525
{
2626
parent::setUp();
27-
28-
$request = new Request();
29-
$response = new Response();
30-
$this->controller = new Controller($request, $response);
31-
$registry = new ComponentRegistry($this->controller);
32-
$this->component = new ApiPaginationComponent($registry);
3327
}
3428

3529
/**
@@ -43,4 +37,21 @@ public function tearDown()
4337

4438
unset($this->component, $this->controller);
4539
}
40+
41+
public function testInit()
42+
{
43+
$request = new Request('/');
44+
$response = $this->getMock('Cake\Network\Response');
45+
46+
$controller = new Controller($request, $response);
47+
$controller->loadComponent('BryanCrowe/ApiPagination.ApiPagination');
48+
49+
$expected = [
50+
'key' => 'pagination',
51+
'aliases' => [],
52+
'visible' => []
53+
];
54+
55+
$this->assertSame($expected, $controller->ApiPagination->config());
56+
}
4657
}

0 commit comments

Comments
 (0)