@@ -13,67 +13,67 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class QueryExecuterTest extends \PHPUnit_Framework_TestCase { |
| 15 | 15 | |
| 16 | - private function getHttpMock( $params ) { |
|
| 17 | - $http = $this->getMockBuilder( 'Asparagus\Http' ) |
|
| 16 | + private function getHttpMock($params) { |
|
| 17 | + $http = $this->getMockBuilder('Asparagus\Http') |
|
| 18 | 18 | ->disableOriginalConstructor() |
| 19 | 19 | ->getMock(); |
| 20 | 20 | |
| 21 | - $http->expects( $this->once() ) |
|
| 22 | - ->method( 'request' ) |
|
| 21 | + $http->expects($this->once()) |
|
| 22 | + ->method('request') |
|
| 23 | 23 | ->with( |
| 24 | - $this->equalTo( 'test.example.com' ), |
|
| 25 | - $this->equalTo( $params ) |
|
| 24 | + $this->equalTo('test.example.com'), |
|
| 25 | + $this->equalTo($params) |
|
| 26 | 26 | ) |
| 27 | - ->will( $this->returnValue( '{"results":{"bindings":"~=[,,_,,]:3"}}' ) ); |
|
| 27 | + ->will($this->returnValue('{"results":{"bindings":"~=[,,_,,]:3"}}')); |
|
| 28 | 28 | |
| 29 | 29 | return $http; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function testExecute() { |
| 33 | - $http = $this->getHttpMock( array( |
|
| 33 | + $http = $this->getHttpMock(array( |
|
| 34 | 34 | 'query' => 'FooBar', |
| 35 | 35 | 'format' => 'json' |
| 36 | - ) ); |
|
| 36 | + )); |
|
| 37 | 37 | |
| 38 | - $queryExecuter = new QueryExecuter( 'test.example.com', array(), $http ); |
|
| 39 | - $result = $queryExecuter->execute( 'FooBar' ); |
|
| 38 | + $queryExecuter = new QueryExecuter('test.example.com', array(), $http); |
|
| 39 | + $result = $queryExecuter->execute('FooBar'); |
|
| 40 | 40 | |
| 41 | - $this->assertEquals( '~=[,,_,,]:3', $result ); |
|
| 41 | + $this->assertEquals('~=[,,_,,]:3', $result); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function testExecuteCustomParams() { |
| 45 | - $http = $this->getHttpMock( array( |
|
| 45 | + $http = $this->getHttpMock(array( |
|
| 46 | 46 | 'fancy-query' => 'FooBar', |
| 47 | 47 | 'format-nyan' => 'json' |
| 48 | - ) ); |
|
| 48 | + )); |
|
| 49 | 49 | |
| 50 | - $queryExecuter = new QueryExecuter( 'test.example.com', array( |
|
| 50 | + $queryExecuter = new QueryExecuter('test.example.com', array( |
|
| 51 | 51 | 'queryParam' => 'fancy-query', |
| 52 | 52 | 'formatParam' => 'format-nyan' |
| 53 | - ), $http ); |
|
| 53 | + ), $http); |
|
| 54 | 54 | |
| 55 | - $result = $queryExecuter->execute( 'FooBar' ); |
|
| 55 | + $result = $queryExecuter->execute('FooBar'); |
|
| 56 | 56 | |
| 57 | - $this->assertEquals( '~=[,,_,,]:3', $result ); |
|
| 57 | + $this->assertEquals('~=[,,_,,]:3', $result); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public function testExecuteQueryBuilder() { |
| 61 | - $http = $this->getHttpMock( array( |
|
| 61 | + $http = $this->getHttpMock(array( |
|
| 62 | 62 | 'query' => 'SELECT * WHERE { }', |
| 63 | 63 | 'format' => 'json' |
| 64 | - ) ); |
|
| 64 | + )); |
|
| 65 | 65 | |
| 66 | - $queryExecuter = new QueryExecuter( 'test.example.com', array(), $http ); |
|
| 67 | - $result = $queryExecuter->execute( new QueryBuilder() ); |
|
| 66 | + $queryExecuter = new QueryExecuter('test.example.com', array(), $http); |
|
| 67 | + $result = $queryExecuter->execute(new QueryBuilder()); |
|
| 68 | 68 | |
| 69 | - $this->assertEquals( '~=[,,_,,]:3', $result ); |
|
| 69 | + $this->assertEquals('~=[,,_,,]:3', $result); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function testExecuteInvalidArgument() { |
| 73 | - $queryExecuter = new QueryExecuter( 'test.example.com' ); |
|
| 74 | - $this->setExpectedException( 'InvalidArgumentException' ); |
|
| 73 | + $queryExecuter = new QueryExecuter('test.example.com'); |
|
| 74 | + $this->setExpectedException('InvalidArgumentException'); |
|
| 75 | 75 | |
| 76 | - $queryExecuter->execute( null ); |
|
| 76 | + $queryExecuter->execute(null); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | } |