| Conditions | 1 |
| Paths | 1 |
| Total Lines | 38 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public function testSplashRequestParameterFetcher() |
||
| 12 | { |
||
| 13 | $method = new ReflectionMethod(TestController::class, 'myAction'); |
||
| 14 | $params = $method->getParameters(); |
||
| 15 | |||
| 16 | $splashRequestFetcher = new SplashRequestParameterFetcher(); |
||
| 17 | //$this->assertFalse($splashRequestFetcher->canHandle($params[0])); |
||
| 18 | $this->assertTrue($splashRequestFetcher->canHandle($params[2])); |
||
| 19 | |||
| 20 | $data = $splashRequestFetcher->getFetcherData($params[2]); |
||
| 21 | $this->assertEquals([ |
||
| 22 | 'key' => 'id', |
||
| 23 | 'compulsory' => false, |
||
| 24 | 'default' => null, |
||
| 25 | ], $data); |
||
| 26 | |||
| 27 | $dataCompulsory = $splashRequestFetcher->getFetcherData($params[1]); |
||
| 28 | $this->assertEquals([ |
||
| 29 | 'key' => 'compulsory', |
||
| 30 | 'compulsory' => true, |
||
| 31 | ], $dataCompulsory); |
||
| 32 | |||
| 33 | $request = new ServerRequest( |
||
| 34 | [], |
||
| 35 | [], |
||
| 36 | 'toto/tata', |
||
| 37 | 'GET', |
||
| 38 | 'php://input', |
||
| 39 | [], |
||
| 40 | [], |
||
| 41 | [ |
||
| 42 | 'id' => 42, |
||
| 43 | ] |
||
| 44 | ); |
||
| 45 | $context = new SplashRequestContext($request); |
||
| 46 | |||
| 47 | $this->assertSame(42, $splashRequestFetcher->fetchValue($data, $context)); |
||
| 48 | } |
||
| 49 | } |
||
| 50 |