@@ -2,60 +2,60 @@ |
||
2 | 2 | |
3 | 3 | class IntegrationTest extends TestCase { |
4 | 4 | |
5 | - public function setUp() |
|
6 | - { |
|
7 | - parent::setUp(); |
|
8 | - |
|
9 | - Breadcrumbs::register('home', function($breadcrumbs) { |
|
10 | - $breadcrumbs->push('Home', '/'); |
|
11 | - }); |
|
12 | - |
|
13 | - Breadcrumbs::register('category', function($breadcrumbs, $category) { |
|
14 | - $breadcrumbs->parent('home'); |
|
15 | - $breadcrumbs->push($category->title, '/category/' . $category->id); |
|
16 | - }); |
|
17 | - |
|
18 | - Breadcrumbs::register('post', function($breadcrumbs, $post) { |
|
19 | - $breadcrumbs->parent('category', $post->category); |
|
20 | - $breadcrumbs->push($post->title, '/blog/' . $post->id); |
|
21 | - }); |
|
22 | - |
|
23 | - $this->post = (object) [ |
|
24 | - 'id' => 123, |
|
25 | - 'title' => 'Sample Post', |
|
26 | - 'category' => (object) [ |
|
27 | - 'id' => 456, |
|
28 | - 'title' => 'Sample Category', |
|
29 | - ], |
|
30 | - ]; |
|
31 | - } |
|
32 | - |
|
33 | - public function testGenerate() |
|
34 | - { |
|
35 | - $breadcrumbs = Breadcrumbs::generate('post', $this->post); |
|
36 | - |
|
37 | - $this->assertCount(3, $breadcrumbs); |
|
38 | - |
|
39 | - $this->assertSame('Home', $breadcrumbs[0]->title); |
|
40 | - $this->assertSame('/', $breadcrumbs[0]->url); |
|
41 | - $this->assertTrue($breadcrumbs[0]->first); |
|
42 | - $this->assertFalse($breadcrumbs[0]->last); |
|
43 | - |
|
44 | - $this->assertSame('Sample Category', $breadcrumbs[1]->title); |
|
45 | - $this->assertSame('/category/456', $breadcrumbs[1]->url); |
|
46 | - $this->assertFalse($breadcrumbs[1]->first); |
|
47 | - $this->assertFalse($breadcrumbs[1]->last); |
|
48 | - |
|
49 | - $this->assertSame('Sample Post', $breadcrumbs[2]->title); |
|
50 | - $this->assertSame('/blog/123', $breadcrumbs[2]->url); |
|
51 | - $this->assertFalse($breadcrumbs[2]->first); |
|
52 | - $this->assertTrue($breadcrumbs[2]->last); |
|
53 | - } |
|
54 | - |
|
55 | - public function testRender() |
|
56 | - { |
|
57 | - $html = Breadcrumbs::render('post', $this->post); |
|
58 | - $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../fixtures/integration.html', $html); |
|
59 | - } |
|
5 | + public function setUp() |
|
6 | + { |
|
7 | + parent::setUp(); |
|
8 | + |
|
9 | + Breadcrumbs::register('home', function($breadcrumbs) { |
|
10 | + $breadcrumbs->push('Home', '/'); |
|
11 | + }); |
|
12 | + |
|
13 | + Breadcrumbs::register('category', function($breadcrumbs, $category) { |
|
14 | + $breadcrumbs->parent('home'); |
|
15 | + $breadcrumbs->push($category->title, '/category/' . $category->id); |
|
16 | + }); |
|
17 | + |
|
18 | + Breadcrumbs::register('post', function($breadcrumbs, $post) { |
|
19 | + $breadcrumbs->parent('category', $post->category); |
|
20 | + $breadcrumbs->push($post->title, '/blog/' . $post->id); |
|
21 | + }); |
|
22 | + |
|
23 | + $this->post = (object) [ |
|
24 | + 'id' => 123, |
|
25 | + 'title' => 'Sample Post', |
|
26 | + 'category' => (object) [ |
|
27 | + 'id' => 456, |
|
28 | + 'title' => 'Sample Category', |
|
29 | + ], |
|
30 | + ]; |
|
31 | + } |
|
32 | + |
|
33 | + public function testGenerate() |
|
34 | + { |
|
35 | + $breadcrumbs = Breadcrumbs::generate('post', $this->post); |
|
36 | + |
|
37 | + $this->assertCount(3, $breadcrumbs); |
|
38 | + |
|
39 | + $this->assertSame('Home', $breadcrumbs[0]->title); |
|
40 | + $this->assertSame('/', $breadcrumbs[0]->url); |
|
41 | + $this->assertTrue($breadcrumbs[0]->first); |
|
42 | + $this->assertFalse($breadcrumbs[0]->last); |
|
43 | + |
|
44 | + $this->assertSame('Sample Category', $breadcrumbs[1]->title); |
|
45 | + $this->assertSame('/category/456', $breadcrumbs[1]->url); |
|
46 | + $this->assertFalse($breadcrumbs[1]->first); |
|
47 | + $this->assertFalse($breadcrumbs[1]->last); |
|
48 | + |
|
49 | + $this->assertSame('Sample Post', $breadcrumbs[2]->title); |
|
50 | + $this->assertSame('/blog/123', $breadcrumbs[2]->url); |
|
51 | + $this->assertFalse($breadcrumbs[2]->first); |
|
52 | + $this->assertTrue($breadcrumbs[2]->last); |
|
53 | + } |
|
54 | + |
|
55 | + public function testRender() |
|
56 | + { |
|
57 | + $html = Breadcrumbs::render('post', $this->post); |
|
58 | + $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../fixtures/integration.html', $html); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | } |
@@ -2,6 +2,6 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - 'view' => 'breadcrumbs::bootstrap3', |
|
5 | + 'view' => 'breadcrumbs::bootstrap3', |
|
6 | 6 | |
7 | 7 | ]; |