|
4 | 4 | use Collective\Html\HtmlBuilder;
|
5 | 5 | use Illuminate\Contracts\View\Factory;
|
6 | 6 | use Illuminate\Http\Request;
|
| 7 | +use Illuminate\Routing\Route; |
7 | 8 | use Illuminate\Routing\RouteCollection;
|
8 | 9 | use Illuminate\Routing\UrlGenerator;
|
9 | 10 | use Illuminate\Support\Collection;
|
@@ -99,6 +100,24 @@ public function testOpeningForm()
|
99 | 100 | $form5);
|
100 | 101 | }
|
101 | 102 |
|
| 103 | + public function testFormRoute() |
| 104 | + { |
| 105 | + $routes = new RouteCollection(); |
| 106 | + $routes->get('user/{id}'); |
| 107 | + $routes->add(new Route(['GET'], 'user/{id}', ['as' => 'user.show'])); |
| 108 | + $this->urlGenerator->setRoutes($routes); |
| 109 | + |
| 110 | + $form1 = $this->formBuilder->open(['method' => 'GET', 'route' => ['user.show', 1, 'foo' => 'bar']]); |
| 111 | + $form2 = $this->formBuilder->open(['method' => 'GET', 'route' => ['user.show', 'id' => 2, 'foo' => 'bar']]); |
| 112 | + $form3 = $this->formBuilder->open(['method' => 'GET', 'route' => ['user.show', [3, 'foo' => 'bar']]]); |
| 113 | + $form4 = $this->formBuilder->open(['method' => 'GET', 'route' => ['user.show', ['id' => 4, 'foo' => 'bar']]]); |
| 114 | + |
| 115 | + $this->assertEquals('<form method="GET" action="http://localhost/user/1?foo=bar" accept-charset="UTF-8">', $form1); |
| 116 | + $this->assertEquals('<form method="GET" action="http://localhost/user/2?foo=bar" accept-charset="UTF-8">', $form2); |
| 117 | + $this->assertEquals('<form method="GET" action="http://localhost/user/3?foo=bar" accept-charset="UTF-8">', $form3); |
| 118 | + $this->assertEquals('<form method="GET" action="http://localhost/user/4?foo=bar" accept-charset="UTF-8">', $form4); |
| 119 | + } |
| 120 | + |
102 | 121 | public function testClosingForm()
|
103 | 122 | {
|
104 | 123 | $this->assertEquals('</form>', $this->formBuilder->close());
|
|
0 commit comments