Skip to content

Commit

Permalink
Add test for adding curl opts
Browse files Browse the repository at this point in the history
  • Loading branch information
willwashburn committed May 18, 2016
1 parent 319a473 commit b2bf716
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/ExpandLinksTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Mockery as M;

/**
* Class ExpandLinkTest.
*/
Expand Down Expand Up @@ -90,4 +92,37 @@ public function canonicalLinksProvider()
['http://www.practicallyfunctional.com/so-creative-18-delicious-game-day-appetizers/', 'http://www.practicallyfunctional.com/so-creative-18-delicious-game-day-appetizers/'], // protocol issues
];
}

public function test_setting_curl_options_works()
{

$expected_curl_opts = [
CURLOPT_FOLLOWLOCATION => false,
];

$curl
= M::mock(\WillWashburn\Curl::class)
->shouldReceive('curl_init')->getMock()
->shouldReceive('curl_exec')->getMock()
->shouldReceive('curl_close')->getMock()
->shouldReceive('curl_getinfo')->getMock()
->shouldReceive('curl_setopt_array')
->with(M::any(), M::on(function ($arg) use ($expected_curl_opts) {

foreach ( array_keys($expected_curl_opts) as $key ) {

if ( $arg[$key] != $expected_curl_opts[$key] ) {
return false;
}
}

return true;
}))
->getMock();


$mushroom = new \Mushroom\Mushroom($curl);

$mushroom->expand('http://www.foobar.com', ['curl_opts' => $expected_curl_opts]);
}
}

0 comments on commit b2bf716

Please sign in to comment.