-
Notifications
You must be signed in to change notification settings - Fork 3
test enhancement #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
904f454
test enhancement
peter279k 1eb9911
remove unused use class
peter279k f694a99
approve the request changes and modify Curl test
peter279k 763bba0
Merge https://github.com/brick/std
peter279k d737b84
approve the request changes for the PR review
peter279k 459caf8
fix the expectedExceptionMessage
peter279k 2a50aa5
approve request changes,createDirectoryTwice test
peter279k 4ef7fc0
modify the correct test method name
peter279k f40d0f9
Merge https://github.com/brick/std
peter279k 539d1eb
enhance the test approaches
peter279k 9c535f0
Fix composer.json conflicts
peter279k fffd40b
Add ext-curl extension check
peter279k 99181d6
Accept request changes for directory paths
peter279k 8d3d328
Add offsetExistsProvider and tmp dir for tests
peter279k 3520c0f
Remove ./tmp directory
peter279k 2f2c225
Remove prefixed ./ because it's useless
peter279k 2033353
Remove unused .txt extension
peter279k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Brick\Std\Tests\Curl; | ||
|
|
||
| use Brick\Std\Curl\Curl; | ||
| use PHPUnit\Framework\TestCase; | ||
|
|
||
| class CurlTest extends TestCase | ||
| { | ||
| public function testGetInfoWithSpecificOption() | ||
| { | ||
| $curl = new Curl(); | ||
|
|
||
| $this->assertSame(0, $curl->getInfo(CURLINFO_HTTP_CODE)); | ||
| } | ||
|
|
||
| public function testGetInfo() | ||
| { | ||
| $expectedArray = [ | ||
| 'url' => '', | ||
| 'content_type' => null, | ||
| 'http_code' => 0, | ||
| 'header_size' => 0, | ||
| 'request_size' => 0, | ||
| 'filetime' => 0, | ||
| 'ssl_verify_result' => 0, | ||
| 'redirect_count' => 0, | ||
| 'total_time' => 0.0, | ||
| 'namelookup_time' => 0.0, | ||
| 'connect_time' => 0.0, | ||
| 'pretransfer_time' => 0.0, | ||
| 'size_upload' => 0.0, | ||
| 'size_download' => 0.0, | ||
| 'speed_download' => 0.0, | ||
| 'speed_upload' => 0.0, | ||
| 'download_content_length' => -1.0, | ||
| 'upload_content_length' => -1.0, | ||
| 'starttransfer_time' => 0.0, | ||
| 'redirect_time' => 0.0, | ||
| 'redirect_url' => '', | ||
| 'primary_ip' => '', | ||
| 'certinfo' => [], | ||
| 'primary_port' => 0, | ||
| 'local_ip' => '', | ||
| 'local_port' => 0, | ||
| ]; | ||
| $curl = new Curl(); | ||
|
|
||
| $this->assertSame($expectedArray, $curl->getInfo()); | ||
| } | ||
|
|
||
| public function testSetOption() | ||
| { | ||
| $curl = new Curl(); | ||
| $curl->setOption(CURLOPT_URL, 'http://example.com'); | ||
|
|
||
| $this->assertSame('http://example.com', $curl->getInfo(CURLINFO_EFFECTIVE_URL)); | ||
| } | ||
|
|
||
| public function testSetOptions() | ||
| { | ||
| $curlOpts = [ | ||
| CURLOPT_URL => 'http://example.com', | ||
| ]; | ||
| $curl = new Curl(); | ||
| $curl->setOptions($curlOpts); | ||
|
|
||
| $this->assertSame('http://example.com', $curl->getInfo(CURLINFO_EFFECTIVE_URL)); | ||
| } | ||
|
|
||
| public function testGetVersion() | ||
| { | ||
| $curl = new Curl(); | ||
|
|
||
| $this->assertInternalType('array', $curl->getVersion()); | ||
| $this->assertContains('version_number', $curl->getVersion()); | ||
| } | ||
|
|
||
| public function testExecute() | ||
| { | ||
| $curl = new Curl('file://' . __FILE__); | ||
|
|
||
| $this->assertSame('<?php', substr($curl->execute(), 0, 5)); | ||
| } | ||
|
|
||
| /** | ||
| * @expectedException Brick\Std\Curl\CurlException | ||
| * @expectedExceptionMessage cURL request failed: No URL set!. | ||
| */ | ||
| public function testExecuteShouldThrowCurlException() | ||
| { | ||
| $curl = new Curl(); | ||
| $curl->execute(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.