| 1 | <?php |
||
| 9 | class RequestFactoryTest extends TestCase |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var \Venta\Http\Factory\RequestFactory |
||
| 13 | */ |
||
| 14 | protected $factory; |
||
| 15 | |||
| 16 | public function setUp() |
||
| 17 | { |
||
| 18 | $this->factory = new \Venta\Http\Factory\RequestFactory; |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @test |
||
| 23 | */ |
||
| 24 | public function canCreateRequestWithUriInstance() |
||
| 25 | { |
||
| 26 | $uri = new Uri('/foo.bar'); |
||
| 27 | $request = $this->factory->createServerRequest('GET', $uri); |
||
| 28 | $this->assertInstanceOf(\Venta\Contracts\Http\Request::class, $request); |
||
| 29 | $this->assertSame('GET', $request->getMethod()); |
||
| 30 | $this->assertSame($uri, $request->getUri()); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @test |
||
| 35 | */ |
||
| 36 | public function canCreateServerRequestFromGlobals() |
||
| 37 | { |
||
| 38 | $request = $this->factory->createServerRequestFromGlobals(); |
||
| 39 | $this->assertInstanceOf(\Venta\Contracts\Http\Request::class, $request); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @test |
||
| 44 | */ |
||
| 45 | public function canCreateServerRequestWithParams() |
||
| 46 | { |
||
| 47 | $request = $this->factory->createServerRequest('GET', '/foo.bar'); |
||
| 48 | $this->assertInstanceOf(\Venta\Contracts\Http\Request::class, $request); |
||
| 49 | $this->assertSame('GET', $request->getMethod()); |
||
| 50 | $this->assertSame('/foo.bar', $request->getUri()->__toString()); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @test |
||
| 55 | */ |
||
| 56 | public function implementsRequestFactoryContract() |
||
| 57 | { |
||
| 58 | $this->assertInstanceOf(\Venta\Contracts\Http\RequestFactory::class, new \Venta\Http\Factory\RequestFactory); |
||
| 59 | } |
||
| 60 | } |