14 use PHPUnit4And6Compat;
17 $requestFactory = $this->getMock( HttpRequestFactory::class );
18 $requestFactory->method(
'create' )->willReturn(
$request );
19 return $requestFactory;
23 $request = $this->getMockBuilder( MWHttpRequest::class )->disableOriginalConstructor()->getMock();
24 $request->method(
'execute' )->willReturn( \Status::newGood( 200 ) );
25 $request->method(
'getContent' )->willReturn( $content );
33 "vars" : [
"x",
"y",
"z" ]
39 "value" :
"http://wikiba.se/ontology#Dump"
43 "value" :
"http://creativecommons.org/ns#license"
47 "value" :
"http://creativecommons.org/publicdomain/zero/1.0/"
52 "value" :
"http://wikiba.se/ontology#Dump"
67 $result = $client->query(
"TEST SPARQL" );
68 $this->assertCount( 2, $result );
69 $this->assertEquals(
'http://wikiba.se/ontology#Dump', $result[0][
'x'] );
70 $this->assertEquals(
'http://creativecommons.org/ns#license', $result[0][
'y'] );
71 $this->assertEquals(
'0.1.0', $result[1][
'z'] );
72 $this->assertNull( $result[1][
'y'] );
74 $result = $client->query(
"TEST SPARQL 2",
true );
75 $this->assertCount( 2, $result );
76 $this->assertEquals(
'uri', $result[0][
'x'][
'type'] );
77 $this->assertEquals(
'http://wikiba.se/ontology#Dump', $result[0][
'x'][
'value'] );
78 $this->assertEquals(
'literal', $result[1][
'z'][
'type'] );
79 $this->assertEquals(
'0.1.0', $result[1][
'z'][
'value'] );
80 $this->assertNull( $result[1][
'y'] );
87 $request = $this->getMockBuilder( MWHttpRequest::class )->disableOriginalConstructor()->getMock();
90 $request->method(
'execute' )->willReturn( \Status::newFatal(
"Bad query" ) );
91 $result = $client->query(
"TEST SPARQL 3" );
97 'TEST ัะตัั SPARQL 4 ',
102 'query=TEST+%D1%82%D0%B5%D1%81%D1%82+SPARQL+4+',
104 'maxQueryTimeMillis=30000',
118 'maxQueryTimeMillis=30000',
130 'maxQueryTimeMillis=1000',
139 'userAgent' =>
'My Test',
140 'randomOption' =>
'duck',
145 'userAgent' =>
'My Test',
146 'randomOption' =>
'duck',
162 $requestFactory = $this->getMock( HttpRequestFactory::class );
163 $client =
new SparqlClient(
'http://acme.test/', $requestFactory );
167 $requestFactory->method(
'create' )->willReturnCallback(
168 function ( $url,
$options ) use (
$request, $expectedUrl, $expectedOptions ) {
169 foreach ( $expectedUrl as $eurl ) {
170 $this->assertContains( $eurl, $url );
172 foreach ( $expectedOptions as $ekey => $evalue ) {
173 $this->assertArrayHasKey( $ekey,
$options );
174 $this->assertEquals(
$options[$ekey], $evalue );
181 $client->setClientOptions(
$options );
183 if ( !is_null( $timeout ) ) {
184 $client->setTimeout( $timeout );
187 $result = $client->query( $sparql );
Various HTTP related functions.
static userAgent()
A standard user-agent we can use for external requests.
This wrapper class will call out to curl (if available) or fallback to regular PHP if necessary for h...
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options