Skip to content

Commit

Permalink
Move option check from CachedCurlRequest to CurlRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
mwjames committed Nov 23, 2015
1 parent 1c754ea commit f37d201
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ tools:

checks:
php:
psr2_class_declaration: false
psr2_switch_declaration: false
sql_injection_vulnerabilities: true
security_vulnerabilities: true
no_eval: true
22 changes: 0 additions & 22 deletions src/CachedCurlRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,6 @@ public function isFromCache() {
return $this->isFromCache;
}

/**
* @since 1.3
*
* @param string $name
* @param mixed $value
*/
public function setOption( $name, $value ) {

$this->options[$name] = $value;

// Internal ONOI options are not further relayed
if ( strpos( $name, 'ONOI_HTTP_REQUEST' ) !== false ) {
return;
}

curl_setopt(
$this->handle,
$name,
$value
);
}

/**
* @since 1.0
*
Expand Down
7 changes: 6 additions & 1 deletion src/CurlRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CurlRequest implements HttpRequest {
/**
* @var resource
*/
protected $handle;
private $handle;

/**
* @var array
Expand Down Expand Up @@ -73,6 +73,11 @@ public function setOption( $name, $value ) {

$this->options[$name] = $value;

// Internal ONOI options are not further relayed
if ( strpos( $name, 'ONOI_HTTP_REQUEST' ) !== false ) {
return;
}

curl_setopt(
$this->handle,
$name,
Expand Down
11 changes: 11 additions & 0 deletions tests/phpunit/Unit/CurlRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,15 @@ public function testExecuteForNullUrl() {
);
}

public function testSetOptionUsingOnoiSpecificConstantDoesNotCauseAnyFailureWithCurl_Setopt() {

$instance = new CurlRequest( curl_init( null ) );
$instance->setOption( ONOI_HTTP_REQUEST_RESPONSECACHE_TTL, 42 );

$this->assertEquals(
42,
$instance->getOption( ONOI_HTTP_REQUEST_RESPONSECACHE_TTL )
);
}

}

0 comments on commit f37d201

Please sign in to comment.