├── .gitignore ├── .travis.yml ├── Curl.php ├── README.md ├── codeception.yml ├── composer.json ├── composer.lock └── tests ├── _bootstrap.php ├── _data └── .gitignore ├── _envs └── .gitignore ├── _output └── .gitignore ├── _support ├── AcceptanceTester.php ├── FunctionalTester.php ├── Helper │ ├── Acceptance.php │ ├── Functional.php │ └── Unit.php ├── UnitTester.php └── _generated │ ├── AcceptanceTesterActions.php │ ├── FunctionalTesterActions.php │ └── UnitTesterActions.php ├── acceptance.suite.yml ├── acceptance └── _bootstrap.php ├── functional.suite.yml ├── functional ├── _bootstrap.php └── httpMockCest.php ├── unit.suite.yml └── unit ├── CurlTest.php └── _bootstrap.php /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | build/logs -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - '7.2' 4 | - '7.3' 5 | - '7.4' 6 | - '8.0.1' 7 | branches: 8 | only: 9 | - master 10 | - develop 11 | install: 12 | - composer update 13 | script: 14 | - XDEBUG_MODE=coverage vendor/bin/codecept run --coverage-xml ./../../build/logs/clover.xml 15 | addons: 16 | code_climate: 17 | repo_token: 24b886eb6df6abd48cb812de2c20b9311d0444f30043bdf4d254116e5225ed84 18 | after_success: 19 | - vendor/bin/test-reporter -------------------------------------------------------------------------------- /Curl.php: -------------------------------------------------------------------------------- 1 | 9 | * @copyright 2013-2017 Nils Gajsek 10 | * @license http://opensource.org/licenses/MIT MIT Public 11 | * @version 1.3.0 12 | * @link http://www.linslin.org 13 | * 14 | */ 15 | 16 | namespace linslin\yii2\curl; 17 | 18 | use Yii; 19 | 20 | 21 | /** 22 | * Class Curl 23 | * @package linslin\yii2\curl 24 | */ 25 | class Curl 26 | { 27 | // ################################################ class vars // ################################################ 28 | 29 | /** 30 | * @var string|boolean 31 | * Holds response data right after sending a request. 32 | */ 33 | public $response = null; 34 | 35 | /** 36 | * @var null|integer 37 | * Error code holder: https://curl.haxx.se/libcurl/c/libcurl-errors.html 38 | */ 39 | public $errorCode = null; 40 | 41 | /** 42 | * @var null|string 43 | * Error text holder: http://php.net/manual/en/function.curl-strerror.php 44 | */ 45 | public $errorText = null; 46 | 47 | /** 48 | * @var integer HTTP-Status Code 49 | * This value will hold HTTP-Status Code. False if request was not successful. 50 | */ 51 | public $responseCode = null; 52 | 53 | /** 54 | * @var string|null HTTP Response Charset 55 | * (taken from Content-type header) 56 | */ 57 | public $responseCharset = null; 58 | 59 | /** 60 | * @var int HTTP Response Length 61 | * (taken from Content-length header, or strlen() of downloaded content) 62 | */ 63 | public $responseLength = -1; 64 | 65 | /** 66 | * @var string|null HTTP Response Content Type 67 | * (taken from Content-type header) 68 | */ 69 | public $responseType = null; 70 | 71 | /** 72 | * @var array|null HTTP Response headers 73 | * Lists response header in an array if CURLOPT_HEADER is set to true. 74 | */ 75 | public $responseHeaders = null; 76 | 77 | /** 78 | * @var array HTTP-Status Code 79 | * Custom options holder 80 | */ 81 | protected $_options = []; 82 | 83 | /** 84 | * @var array 85 | * Hold array of get params to send with the request 86 | */ 87 | protected $_getParams = []; 88 | 89 | /** 90 | * @var array 91 | * Hold array of post params to send with the request 92 | */ 93 | protected $_postParams = []; 94 | 95 | /** 96 | * @var resource|null 97 | * Holds cURL-Handler 98 | */ 99 | public $curl = null; 100 | 101 | /** 102 | * @var string 103 | * hold base URL 104 | */ 105 | protected $_baseUrl = ''; 106 | 107 | /** 108 | * @var array default curl options 109 | * Default curl options 110 | */ 111 | protected $_defaultOptions = [ 112 | CURLOPT_USERAGENT => 'Yii2-Curl-Agent', 113 | CURLOPT_TIMEOUT => 30, 114 | CURLOPT_CONNECTTIMEOUT => 30, 115 | CURLOPT_RETURNTRANSFER => true, 116 | CURLOPT_HEADER => true, 117 | ]; 118 | 119 | 120 | 121 | // ############################################### class methods // ############################################## 122 | 123 | /** 124 | * Start performing GET-HTTP-Request 125 | * 126 | * @param string $url 127 | * @param boolean $raw if response body contains JSON and should be decoded 128 | * 129 | * @return mixed 130 | * @throws \Exception 131 | */ 132 | public function get($url, $raw = true) 133 | { 134 | $this->_baseUrl = $url; 135 | return $this->_httpRequest('GET', $raw); 136 | } 137 | 138 | 139 | 140 | /** 141 | * Start performing HEAD-HTTP-Request 142 | * 143 | * @param string $url 144 | * 145 | * @return mixed 146 | * @throws \Exception 147 | */ 148 | public function head($url) 149 | { 150 | $this->_baseUrl = $url; 151 | return $this->_httpRequest('HEAD'); 152 | } 153 | 154 | 155 | /** 156 | * Start performing POST-HTTP-Request 157 | * 158 | * @param string $url 159 | * @param boolean $raw if response body contains JSON and should be decoded 160 | * 161 | * @return mixed 162 | * @throws \Exception 163 | */ 164 | public function post($url, $raw = true) 165 | { 166 | $this->_baseUrl = $url; 167 | return $this->_httpRequest('POST', $raw); 168 | } 169 | 170 | 171 | /** 172 | * Start performing PUT-HTTP-Request 173 | * 174 | * @param string $url 175 | * @param boolean $raw if response body contains JSON and should be decoded 176 | * 177 | * @return mixed 178 | * @throws \Exception 179 | */ 180 | public function put($url, $raw = true) 181 | { 182 | $this->_baseUrl = $url; 183 | return $this->_httpRequest('PUT', $raw); 184 | } 185 | 186 | 187 | /** 188 | * Start performing PATCH-HTTP-Request 189 | * 190 | * @param string $url 191 | * @param bool $raw if response body contains JSON and should be decoded 192 | * 193 | * @return mixed 194 | * @throws \Exception 195 | */ 196 | public function patch($url, $raw = true) 197 | { 198 | $this->_baseUrl = $url; 199 | $this->setHeaders([ 200 | 'X-HTTP-Method-Override' => 'PATCH' 201 | ]); 202 | return $this->_httpRequest('PATCH',$raw); 203 | } 204 | 205 | 206 | /** 207 | * Start performing DELETE-HTTP-Request 208 | * 209 | * @param string $url 210 | * @param boolean $raw if response body contains JSON and should be decoded 211 | * 212 | * @return mixed 213 | * @throws \Exception 214 | */ 215 | public function delete($url, $raw = true) 216 | { 217 | $this->_baseUrl = $url; 218 | return $this->_httpRequest('DELETE', $raw); 219 | } 220 | 221 | /** 222 | * Start performing OPTIONS-HTTP-Request 223 | * 224 | * @param string $url 225 | * @param bool $raw if response body contains JSON and should be decoded 226 | * 227 | * @return mixed 228 | * @throws \Exception 229 | */ 230 | public function options($url, $raw = true) 231 | { 232 | $this->_baseUrl = $url; 233 | return $this->_httpRequest('OPTIONS', $raw); 234 | } 235 | 236 | 237 | /** 238 | * Set curl option 239 | * 240 | * @param string $key 241 | * @param mixed $value 242 | * 243 | * @return $this 244 | */ 245 | public function setOption($key, $value) 246 | { 247 | //set value 248 | if (array_key_exists($key, $this->_defaultOptions) && $key !== CURLOPT_WRITEFUNCTION) { 249 | $this->_defaultOptions[$key] = $value; 250 | } else { 251 | $this->_options[$key] = $value; 252 | } 253 | 254 | //return self 255 | return $this; 256 | } 257 | 258 | 259 | /** 260 | * Set get params 261 | * 262 | * @param array $params 263 | * @return $this 264 | */ 265 | public function setGetParams($params) 266 | { 267 | if (is_array($params)) { 268 | foreach ($params as $key => $value) { 269 | $this->_getParams[$key] = $value; 270 | } 271 | } 272 | 273 | //return self 274 | return $this; 275 | } 276 | 277 | 278 | /** 279 | * Set get params 280 | * 281 | * @param array $params 282 | * @return $this 283 | */ 284 | public function setPostParams($params) 285 | { 286 | if (is_array($params)) { 287 | $this->setOption( 288 | CURLOPT_POSTFIELDS, 289 | http_build_query($params) 290 | ); 291 | } 292 | 293 | //return self 294 | return $this; 295 | } 296 | 297 | 298 | /** 299 | * Set raw post data allows you to post any data format. 300 | * 301 | * @param mixed $data 302 | * @return $this 303 | */ 304 | public function setRawPostData($data) 305 | { 306 | $this->setOption( 307 | CURLOPT_POSTFIELDS, 308 | $data 309 | ); 310 | 311 | //return self 312 | return $this; 313 | } 314 | 315 | 316 | /** 317 | * Set get params 318 | * 319 | * @param string $data 320 | * @return $this 321 | */ 322 | public function setRequestBody($data) 323 | { 324 | if (is_string($data)) { 325 | $this->setOption( 326 | CURLOPT_POSTFIELDS, 327 | $data 328 | ); 329 | } 330 | 331 | //return self 332 | return $this; 333 | } 334 | 335 | 336 | /** 337 | * Get URL - return URL parsed with given params 338 | * 339 | * @return string The full URL with parsed get params 340 | */ 341 | public function getUrl() 342 | { 343 | if (Count($this->_getParams) > 0) { 344 | return $this->_baseUrl.'?'.http_build_query($this->_getParams); 345 | } else { 346 | return $this->_baseUrl; 347 | } 348 | } 349 | 350 | 351 | /** 352 | * Set curl options 353 | * 354 | * @param array $options 355 | * 356 | * @return $this 357 | */ 358 | public function setOptions($options) 359 | { 360 | $this->_options = $options + $this->_options; 361 | 362 | return $this; 363 | } 364 | 365 | 366 | /** 367 | * Set multiple headers for request. 368 | * 369 | * @param array $headers 370 | * 371 | * @return $this 372 | */ 373 | public function setHeaders($headers) 374 | { 375 | if (is_array($headers)) { 376 | 377 | //init 378 | $parsedHeader = []; 379 | 380 | //collect currently set headers 381 | foreach ($this->getRequestHeaders() as $header => $value) { 382 | array_push($parsedHeader, $header.':'.$value); 383 | } 384 | 385 | //parse header into right format key:value 386 | foreach ($headers as $header => $value) { 387 | array_push($parsedHeader, $header.':'.$value); 388 | } 389 | 390 | //set headers 391 | $this->setOption( 392 | CURLOPT_HTTPHEADER, 393 | $parsedHeader 394 | ); 395 | } 396 | 397 | return $this; 398 | } 399 | 400 | 401 | /** 402 | * Set a single header for request. 403 | * 404 | * @param string $header 405 | * @param string $value 406 | * 407 | * @return $this 408 | */ 409 | public function setHeader($header, $value) 410 | { 411 | //init 412 | $parsedHeader = []; 413 | 414 | //collect currently set headers 415 | foreach ($this->getRequestHeaders() as $headerToSet => $valueToSet) { 416 | array_push($parsedHeader, $headerToSet.':'.$valueToSet); 417 | } 418 | 419 | //add override new header 420 | if (strlen($header) > 0) { 421 | array_push($parsedHeader, $header.':'.$value); 422 | } 423 | 424 | //set headers 425 | $this->setOption( 426 | CURLOPT_HTTPHEADER, 427 | $parsedHeader 428 | ); 429 | 430 | return $this; 431 | } 432 | 433 | 434 | /** 435 | * Unset a single header. 436 | * 437 | * @param string $header 438 | * 439 | * @return $this 440 | */ 441 | public function unsetHeader($header) 442 | { 443 | //init 444 | $parsedHeader = []; 445 | 446 | //collect currently set headers and filter "unset" header param. 447 | foreach ($this->getRequestHeaders() as $headerToSet => $valueToSet) { 448 | if ($header !== $headerToSet) { 449 | array_push($parsedHeader, $headerToSet.':'.$valueToSet); 450 | } 451 | } 452 | 453 | //set headers 454 | $this->setOption( 455 | CURLOPT_HTTPHEADER, 456 | $parsedHeader 457 | ); 458 | 459 | return $this; 460 | } 461 | 462 | 463 | /** 464 | * Get all request headers as key:value array 465 | * 466 | * @return array 467 | */ 468 | public function getRequestHeaders() 469 | { 470 | //Init 471 | $requestHeaders = $this->getOption(CURLOPT_HTTPHEADER); 472 | $parsedRequestHeaders = []; 473 | 474 | if (is_array($requestHeaders)) { 475 | foreach ($requestHeaders as $headerValue) { 476 | list ($key, $value) = explode(':', $headerValue, 2); 477 | $parsedRequestHeaders[$key] = $value; 478 | } 479 | } 480 | 481 | return $parsedRequestHeaders; 482 | } 483 | 484 | 485 | /** 486 | * Get specific request header as key:value array 487 | * 488 | * @param string $headerKey 489 | * 490 | * @return string|null 491 | */ 492 | public function getRequestHeader($headerKey) 493 | { 494 | //Init 495 | $parsedRequestHeaders = $this->getRequestHeaders(); 496 | 497 | return isset($parsedRequestHeaders[$headerKey]) ? $parsedRequestHeaders[$headerKey] : null; 498 | } 499 | 500 | 501 | /** 502 | * Unset a single curl option 503 | * 504 | * @param string $key 505 | * 506 | * @return $this 507 | */ 508 | public function unsetOption($key) 509 | { 510 | //reset a single option if its set already 511 | if (isset($this->_options[$key])) { 512 | unset($this->_options[$key]); 513 | } 514 | 515 | return $this; 516 | } 517 | 518 | 519 | /** 520 | * Unset all curl option, excluding default options. 521 | * 522 | * @return $this 523 | */ 524 | public function unsetOptions() 525 | { 526 | //reset all options 527 | if (isset($this->_options)) { 528 | $this->_options = []; 529 | } 530 | 531 | return $this; 532 | } 533 | 534 | 535 | /** 536 | * Total reset of options, responses, etc. 537 | * 538 | * @return $this 539 | */ 540 | public function reset() 541 | { 542 | if ($this->curl !== null) { 543 | curl_close($this->curl); //stop curl 544 | } 545 | 546 | //reset all options 547 | if (isset($this->_options)) { 548 | $this->_options = []; 549 | } 550 | 551 | //reset response & status params 552 | $this->curl = null; 553 | $this->errorCode = null; 554 | $this->response = null; 555 | $this->responseCode = null; 556 | $this->responseCharset = null; 557 | $this->responseLength = -1; 558 | $this->responseType = null; 559 | $this->errorText = null; 560 | $this->_postParams = []; 561 | $this->_getParams = []; 562 | 563 | return $this; 564 | } 565 | 566 | 567 | /** 568 | * Return a single option 569 | * 570 | * @param string|integer $key 571 | * @return mixed|boolean 572 | */ 573 | public function getOption($key) 574 | { 575 | //get merged options depends on default and user options 576 | $mergesOptions = $this->getOptions(); 577 | 578 | //return value or false if key is not set. 579 | return isset($mergesOptions[$key]) ? $mergesOptions[$key] : false; 580 | } 581 | 582 | 583 | /** 584 | * Return merged curl options and keep keys! 585 | * 586 | * @return array 587 | */ 588 | public function getOptions() 589 | { 590 | return $this->_options + $this->_defaultOptions; 591 | } 592 | 593 | 594 | /** 595 | * Get curl info according to http://php.net/manual/de/function.curl-getinfo.php 596 | * 597 | * @param null $opt 598 | * @return array|mixed 599 | */ 600 | public function getInfo($opt = null) 601 | { 602 | if ($this->curl !== null && $opt === null) { 603 | return curl_getinfo($this->curl); 604 | } elseif ($this->curl !== null && $opt !== null) { 605 | return curl_getinfo($this->curl, $opt); 606 | } else { 607 | return []; 608 | } 609 | } 610 | 611 | 612 | /** 613 | * Performs HTTP request 614 | * 615 | * @param string $method 616 | * @param boolean $raw if response body contains JSON and should be decoded -> helper. 617 | * 618 | * @throws \Exception if request failed 619 | * 620 | * @return mixed 621 | */ 622 | protected function _httpRequest($method, $raw = false) 623 | { 624 | //set request type and writer function 625 | $this->setOption(CURLOPT_CUSTOMREQUEST, strtoupper($method)); 626 | 627 | //check if method is head and set no body 628 | if ($method === 'HEAD') { 629 | $this->setOption(CURLOPT_NOBODY, true); 630 | $this->unsetOption(CURLOPT_WRITEFUNCTION); 631 | } 632 | 633 | //setup error reporting and profiling 634 | if (defined('YII_DEBUG') && YII_DEBUG) { 635 | Yii::debug('Start sending cURL-Request: '.$this->getUrl().'\n', __METHOD__); 636 | Yii::beginProfile($method.' '.$this->_baseUrl.'#'.md5(serialize($this->_getDebugData())), __METHOD__); 637 | } 638 | 639 | /** 640 | * proceed curl 641 | */ 642 | $curlOptions = $this->getOptions(); 643 | $this->curl = curl_init($this->getUrl()); 644 | curl_setopt_array($this->curl, $curlOptions); 645 | $response = curl_exec($this->curl); 646 | 647 | //check if curl was successful 648 | if ($response === false) { 649 | 650 | //set error code 651 | $this->errorCode = curl_errno($this->curl); 652 | $this->errorText = curl_strerror($this->errorCode); 653 | 654 | switch ($this->errorCode) { 655 | // 7, 28 = timeout 656 | case 7: 657 | case 28: 658 | $this->responseCode = 'timeout'; 659 | return false; 660 | break; 661 | 662 | default: 663 | return false; 664 | break; 665 | } 666 | } 667 | 668 | //extract header / body data if CURLOPT_HEADER are set to true 669 | if (isset($curlOptions[CURLOPT_HEADER]) && $curlOptions[CURLOPT_HEADER]) { 670 | $this->response = $this->_extractCurlBody($response); 671 | $this->responseHeaders = $this->_extractCurlHeaders($response); 672 | } else { 673 | $this->response = $response; 674 | } 675 | 676 | // Extract additional curl params 677 | $this->_extractAdditionalCurlParameter(); 678 | 679 | //end yii debug profile 680 | if (defined('YII_DEBUG') && YII_DEBUG) { 681 | Yii::debug('End cURL-Request: '.$this->response, __METHOD__); 682 | Yii::endProfile($method.' '.$this->getUrl().'#'.md5(serialize($this->_getDebugData())), __METHOD__); 683 | } 684 | 685 | //check responseCode and return data/status 686 | if ($this->getOption(CURLOPT_CUSTOMREQUEST) === 'HEAD') { 687 | return true; 688 | } else { 689 | $this->response = $raw ? $this->response : json_decode($this->response, true); 690 | return $this->response; 691 | } 692 | } 693 | 694 | 695 | /** 696 | * Extract additional curl params protected class helper 697 | */ 698 | protected function _extractAdditionalCurlParameter () 699 | { 700 | 701 | /** 702 | * retrieve response code 703 | */ 704 | $this->responseCode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE); 705 | 706 | 707 | /** 708 | * try extract response type & charset. 709 | */ 710 | $this->responseType = curl_getinfo($this->curl, CURLINFO_CONTENT_TYPE); 711 | 712 | if (!is_null($this->responseType) && count(explode(';', $this->responseType)) > 1) { 713 | 714 | list($this->responseType, $possibleCharset) = explode(';', $this->responseType); 715 | 716 | //extract charset 717 | if (preg_match('~^charset=(.+?)$~', trim($possibleCharset), $matches) && isset($matches[1])) { 718 | $this->responseCharset = strtolower($matches[1]); 719 | } 720 | } 721 | 722 | 723 | /** 724 | * try extract response length 725 | */ 726 | $this->responseLength = curl_getinfo($this->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD); 727 | 728 | if((int)$this->responseLength === -1) { 729 | $this->responseLength = strlen($this->response); 730 | } 731 | } 732 | 733 | 734 | /** 735 | * Extract body curl data from response 736 | * 737 | * @param string $response 738 | * @return string 739 | */ 740 | protected function _extractCurlBody ($response) 741 | { 742 | return substr($response, $this->getInfo(CURLINFO_HEADER_SIZE)); 743 | } 744 | 745 | 746 | /** 747 | * Extract header curl data from response 748 | * 749 | * @param string $response 750 | * @return array 751 | */ 752 | protected function _extractCurlHeaders ($response) 753 | { 754 | //Init 755 | $headers = []; 756 | $headerText = substr($response, 0, strpos($response, "\r\n\r\n")); 757 | 758 | foreach (explode("\r\n", $headerText) as $i => $line) { 759 | if ($i === 0) { 760 | $headers['http_code'] = $line; 761 | } else { 762 | list ($key, $value) = explode(':', $line, 2); 763 | $headers[$key] = ltrim($value); 764 | } 765 | } 766 | 767 | return $headers; 768 | } 769 | 770 | 771 | /** 772 | * Collects debug data for serialize 773 | * @return array|bool|mixed 774 | */ 775 | private function _getDebugData () { 776 | 777 | $data = []; 778 | 779 | if (is_array($this->getOption(CURLOPT_POSTFIELDS))) { 780 | foreach ($this->getOption(CURLOPT_POSTFIELDS) as $key => $debugItem) { 781 | if (is_array($debugItem)) { 782 | $data[$key] = $debugItem; 783 | } else if ($debugItem instanceof \CURLFile) { 784 | $data[$key] = [ 785 | 'name' => $debugItem->name, 786 | 'mime' => $debugItem->mime, 787 | 'postname' => $debugItem->postname, 788 | ]; 789 | } // more to come? 790 | } 791 | } else { 792 | $data = $this->getOption(CURLOPT_POSTFIELDS); 793 | } 794 | 795 | return $data; 796 | } 797 | } 798 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | yii2-curl extension 2 | =================== 3 | [![Latest Stable Version](https://poser.pugx.org/linslin/yii2-curl/v/stable)](https://packagist.org/packages/linslin/yii2-curl) 4 | [![Latest Master Build](https://api.travis-ci.org/linslin/Yii2-Curl.svg?branch=master)](https://travis-ci.org/linslin/Yii2-Curl/builds) 5 | [![Test Coverage](https://codeclimate.com/github/linslin/Yii2-Curl/badges/coverage.svg)](https://codeclimate.com/github/linslin/Yii2-Curl/coverage) 6 | [![Total Downloads](https://poser.pugx.org/linslin/yii2-curl/downloads)](https://packagist.org/packages/linslin/yii2-curl) 7 | [![License](https://poser.pugx.org/linslin/yii2-curl/license)](https://packagist.org/packages/linslin/yii2-curl) 8 | 9 | Easy working cURL extension for Yii2, including RESTful support: 10 | 11 | - POST 12 | - GET 13 | - HEAD 14 | - PUT 15 | - PATCH 16 | - DELETE 17 | - OPTIONS 18 | 19 | Requirements 20 | ------------ 21 | - Yii2 22 | - PHP >=7.2.0 || 8.0.1 23 | - ext-curl, ext-json, and php-curl installed 24 | 25 | 26 | Installation 27 | ------------ 28 | 29 | The preferred way to install this extension is through [composer](http://getcomposer.org/download/). 30 | 31 | ```bash 32 | composer require --prefer-dist linslin/yii2-curl "*" 33 | ``` 34 | 35 | 36 | Usage 37 | ----- 38 | 39 | Once the extension is installed, simply use it in your code. The following example shows you how to handling a simple GET Request. 40 | 41 | ```php 42 | use linslin\yii2\curl; 43 | $curl = new curl\Curl(); 44 | 45 | //get http://example.com/ 46 | $response = $curl->get('http://example.com/'); 47 | 48 | if ($curl->errorCode === null) { 49 | echo $response; 50 | } else { 51 | // List of curl error codes here https://curl.haxx.se/libcurl/c/libcurl-errors.html 52 | switch ($curl->errorCode) { 53 | 54 | case 6: 55 | //host unknown example 56 | break; 57 | } 58 | } 59 | ``` 60 | 61 | ```php 62 | // GET request with GET params 63 | // http://example.com/?key=value&scondKey=secondValue 64 | $curl = new curl\Curl(); 65 | $response = $curl->setGetParams([ 66 | 'key' => 'value', 67 | 'secondKey' => 'secondValue' 68 | ]) 69 | ->get('http://example.com/'); 70 | ``` 71 | 72 | 73 | ```php 74 | // POST URL form-urlencoded 75 | $curl = new curl\Curl(); 76 | $response = $curl->setPostParams([ 77 | 'key' => 'value', 78 | 'secondKey' => 'secondValue' 79 | ]) 80 | ->post('http://example.com/'); 81 | ``` 82 | 83 | ```php 84 | // POST RAW JSON 85 | $curl = new curl\Curl(); 86 | $response = $curl->setRawPostData( 87 | json_encode[ 88 | 'key' => 'value', 89 | 'secondKey' => 'secondValue' 90 | ]) 91 | ->post('http://example.com/'); 92 | ``` 93 | 94 | ```php 95 | // POST RAW JSON and auto decode JSON respawn by setting raw = true. 96 | // This is usefull if you expect an JSON response and want to autoparse it. 97 | $curl = new curl\Curl(); 98 | $response = $curl->setRawPostData( 99 | json_encode[ 100 | 'key' => 'value', 101 | 'secondKey' => 'secondValue' 102 | ]) 103 | ->post('http://example.com/', true); 104 | 105 | // JSON decoded response by parsing raw = true in to ->post(). 106 | var_dump($response); 107 | ``` 108 | 109 | ```php 110 | // POST RAW XML 111 | $curl = new curl\Curl(); 112 | $response = $curl->setRawPostData('Test') 113 | ->post('http://example.com/'); 114 | ``` 115 | 116 | 117 | ```php 118 | // POST with special headers 119 | $curl = new curl\Curl(); 120 | $response = $curl->setPostParams([ 121 | 'key' => 'value', 122 | 'secondKey' => 'secondValue' 123 | ]) 124 | ->setHeaders([ 125 | 'Custom-Header' => 'user-b' 126 | ]) 127 | ->post('http://example.com/'); 128 | ``` 129 | 130 | 131 | ```php 132 | // POST JSON with body string & special headers 133 | $curl = new curl\Curl(); 134 | 135 | $params = [ 136 | 'key' => 'value', 137 | 'secondKey' => 'secondValue' 138 | ]; 139 | 140 | $response = $curl->setRequestBody(json_encode($params)) 141 | ->setHeaders([ 142 | 'Content-Type' => 'application/json', 143 | 'Content-Length' => strlen(json_encode($params)) 144 | ]) 145 | ->post('http://example.com/'); 146 | ``` 147 | 148 | ```php 149 | // Avanced POST request with curl options & error handling 150 | $curl = new curl\Curl(); 151 | 152 | $params = [ 153 | 'key' => 'value', 154 | 'secondKey' => 'secondValue' 155 | ]; 156 | 157 | $response = $curl->setRequestBody(json_encode($params)) 158 | ->setOption(CURLOPT_ENCODING, 'gzip') 159 | ->post('http://example.com/'); 160 | 161 | // List of status codes here http://en.wikipedia.org/wiki/List_of_HTTP_status_codes 162 | switch ($curl->responseCode) { 163 | 164 | case 'timeout': 165 | //timeout error logic here 166 | break; 167 | 168 | case 200: 169 | //success logic here 170 | break; 171 | 172 | case 404: 173 | //404 Error logic here 174 | break; 175 | } 176 | 177 | //list response headers 178 | var_dump($curl->responseHeaders); 179 | ``` 180 | 181 | Testing 182 | ------------ 183 | 184 | - Run codeception tests with `vendor/bin/codecept run` in repository root dir. 185 | Run codeception with clover report `XDEBUG_MODE=coverage vendor/bin/codecept run --coverage-xml ./../../build/logs/clover.xml`. 186 | On windows run `vendor\bin\codecept.bat run`. 187 | On windows with clover report run `vendor\bin\codecept.bat run --coverage-xml ./../../build/logs/clover.xml`. 188 | 189 | 190 | Changelog 191 | ------------ 192 | ------------ 193 | ##### Release 1.5.0 - Changelog 194 | - Added PHP 8 support. 195 | - Updated phiremock to v2. 196 | - Removed not needed dependencies from the composer package file (https://github.com/linslin/Yii2-Curl/issues/88). 197 | - Fixed CURLFile object serialization for profiling (https://github.com/linslin/Yii2-Curl/issues/87). 198 | 199 | 200 | ##### Release 1.4.0 - Changelog 201 | - Added support for HTTP-Method OPTIONS. 202 | - Removed deprecated PHP Version support. Minimum PHP Version is now 7.2.0. 203 | Please use version "linslin/yii2-curl 1.3.0" - https://github.com/linslin/Yii2-Curl/releases/tag/1.3.0 if you need PHP 7.1.0+ support. 204 | 205 | 206 | ##### Release 1.3.0 - Changelog 207 | - Fixed HTTP-Method parsing on PATCH request. 208 | - Updated DocBlocks + code refactoring. 209 | - Removed deprecated PHP Version support. Minimum PHP Version is now 7.1.3. 210 | Please use version "linslin/yii2-curl 1.2.1" - https://github.com/linslin/Yii2-Curl/releases/tag/1.2.1 if you need PHP 5.4+ support. 211 | 212 | ##### Release 1.2.2 - Changelog 213 | - Added some new cURL examples into readme.md. 214 | 215 | ##### Release 1.2.1 - Changelog 216 | - Added `setRawPostData([mixed]) [this]` which allows you to post any data format. 217 | 218 | ##### Release 1.2.0 - Changelog 219 | - Added `unsetHeader([string header]) [this]` helper which allows you to unset one specific header. 220 | - Added `setHeader([string header, string value]) [this]` helper which allows you to set one specific header. 221 | - Added `getRequestHeaders() [array]` helper which returns all request headers as an array. 222 | - Added `getRequestHeader([string headerKey]) [string|null]` helper which returns a specific request header as an string. 223 | - Added new test cases for `getRequestHeaders()` and `getRequestHeader()`. 224 | - Readme adjustments. 225 | 226 | ##### Release 1.1.3 - Changelog 227 | - Fixed issue with patch request. 228 | - Fully added functionalTests for 100% coverage. 229 | 230 | ##### Release 1.1.2 - Changelog 231 | - Fixed https://github.com/linslin/Yii2-Curl/issues/59 232 | - Fixed https://github.com/linslin/Yii2-Curl/issues/57 233 | 234 | ##### Release 1.1.1 - Changelog 235 | - Fixed wrong parameter parsing into `_httpRequest()` (thanks to yemexx1) 236 | - Added JSON decode functions tests (thanks to yemexx1) 237 | 238 | ##### Release 1.1.0 - Changelog 239 | - Added `setHeaders() [array]` helper. 240 | - Added `setPostParams() [array]` helper. 241 | - Added `setGetParams() [array]` helper. 242 | - Added `setRequestBody() [string]` helper. 243 | - Added `getUrl()` helper. 244 | - Added API attribute `errorText [string|null]` - holds a string describing the given error code - https://github.com/linslin/Yii2-Curl/issues/49. 245 | - Added functionTests to ensure stability. 246 | - Allow PHP class goodness - https://github.com/linslin/Yii2-Curl/issues/52. 247 | - Fixed header explode - https://github.com/linslin/Yii2-Curl/pull/51. 248 | 249 | ##### Release 1.0.11 - Changelog 250 | - Added API attribute `responseHeaders [array|null]` which returns an array of all response headers. 251 | - Changed `_defaultOptions[CURLOPT_HEADER]` to `true`. 252 | - Profile debugging is only active if constant `YII_DEBUG` is `true`. 253 | 254 | ##### Release 1.0.10 - Changelog 255 | - Fixed PHP notice https://github.com/linslin/Yii2-Curl/issues/39. 256 | 257 | ##### Release 1.0.9 - Changelog 258 | - Added API attribute `responseCode [string|null]` which holds the HTTP response code. 259 | - Added API attribute `responseCharset [string|null]` which holds the response charset. 260 | - Added API attribute `responseLength [integer|null]` which holds the response length. 261 | - Added API attribute `errorCode` which holds the a integer code error like described here: https://curl.haxx.se/libcurl/c/libcurl-errors.html. 262 | - Fixed Issue https://github.com/linslin/Yii2-Curl/issues//36. 263 | - Fixed Issue https://github.com/linslin/Yii2-Curl/issues//37 and removed exception throwing on curl fail. This allow the user to handle the error while using attribute `errorCode`. 264 | 265 | ##### Release 1.0.8 - Changelog 266 | - Added API method `setOptions([array])` which allows to setup multiple options at once. 267 | - Fixed Issue https://github.com/linslin/Yii2-Curl/issues/30. 268 | 269 | ##### Release 1.0.7 - Changelog 270 | - Fixed `getInfo([, int $opt = 0 ])` exception were cURL wasn't initialized before calling `getInfo($opt)`. 271 | 272 | ##### Release 1.0.6 - Changelog 273 | - Added `getInfo([, int $opt = 0 ])` method to retrieve http://php.net/manual/de/function.curl-getinfo.php data. 274 | 275 | ##### Release 1.0.5 - Changelog 276 | - Made `body` callback not depending on HTTP-Status codes anymore. You can retrieve `body` data on any HTTP-Status now. 277 | - Fixed Issue https://github.com/linslin/Yii2-Curl/issues/19 where override default settings break options. 278 | - Added timeout response handling. `$curl->responseCode = 'timeout'` 279 | 280 | ##### Release 1.0.4 - Changelog 281 | - `CURLOPT_RETURNTRANSFER` is now set to true on default - https://github.com/linslin/Yii2-Curl/issues/18 282 | - Readme.md adjustments. 283 | 284 | ##### Release 1.0.3 - Changelog 285 | - Fixed override of user options. https://github.com/linslin/Yii2-Curl/pull/7 286 | - Nice formatted PHP-examples. 287 | - Moved `parent::init();` behavior into unitTest Controller. 288 | 289 | ##### Release 1.0.2 - Changelog 290 | - Added custom params support 291 | - Added custom status code support 292 | - Added POST-Param support and a readme example 293 | - Removed "body" support at request functions. Please use "CURLOPT_POSTFIELDS" to setup a body now. 294 | - Readme modifications 295 | 296 | ##### Release 1.0.1 - Changelog 297 | - Removed widget support 298 | - Edited some spellings + added more examples into readme.md 299 | 300 | ##### Release 1.0 - Changelog 301 | - Official stable release 302 | 303 | 304 | Thanks to 305 | ------------ 306 | ------------ 307 | Mariano Custiel ([@mcustiel](https://github.com/mcustiel)) 308 | 309 | ... and all other contributors. -------------------------------------------------------------------------------- /codeception.yml: -------------------------------------------------------------------------------- 1 | actor: Tester 2 | paths: 3 | tests: tests 4 | log: tests/_output 5 | data: tests/_data 6 | support: tests/_support 7 | envs: tests/_envs 8 | coverage: 9 | enabled: true 10 | include: 11 | - Curl.php 12 | bootstrap: _bootstrap.php 13 | settings: 14 | colors: true 15 | memory_limit: 1024M 16 | extensions: 17 | enabled: 18 | - \Codeception\Extension\Phiremock 19 | - \Codeception\Extension\RunFailed 20 | config: 21 | \Codeception\Extension\Phiremock: 22 | listen: 127.0.0.1:18080 # defaults to 0.0.0.0:8086 23 | bin_path: vendor/bin # defaults to codeception_dir/../vendor/bin 24 | debug: true # defaults to false 25 | start_delay: 1 # default to 0 26 | suites: 27 | - unit 28 | - acceptance 29 | - functional 30 | modules: 31 | enabled: 32 | - Phiremock: 33 | host: 127.0.0.1 # Defaults to localhost 34 | port: 18080 # Defaults to 8086 35 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "linslin/yii2-curl", 3 | "description": "Easy and nice cURL extension with RESTful support for Yii2", 4 | "type": "yii2-extension", 5 | "keywords": ["yii2","extension"," curl", "RESTful"], 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Nils Gajsek", 10 | "email": "info@linslin.org" 11 | } 12 | ], 13 | "require": { 14 | "php": ">=7.2.0 <9.0", 15 | "ext-json": "*", 16 | "ext-curl": "*", 17 | "yiisoft/yii2": "^2.0.0" 18 | }, 19 | "require-dev": { 20 | "guzzlehttp/guzzle": ">=4.1.4 <7.0", 21 | "mcustiel/phiremock": "^2.1", 22 | "mcustiel/phiremock-codeception-extension": "^2.1", 23 | "mcustiel/phiremock-codeception-module": "^1.1.2", 24 | "codeception/module-asserts": "^1.3" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "linslin\\yii2\\curl\\": "" 29 | } 30 | }, 31 | "archive": { 32 | "exclude": [ 33 | "/tests" 34 | ] 35 | }, 36 | "repositories": [ 37 | { 38 | "type": "composer", 39 | "url": "https://asset-packagist.org" 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /tests/_bootstrap.php: -------------------------------------------------------------------------------- 1 | getScenario()->runStep(new \Codeception\Step\Action('takeConnection', func_get_args())); 24 | } 25 | 26 | 27 | /** 28 | * [!] Method is generated. Documentation taken from corresponding module. 29 | * 30 | @throws ClientExceptionInterface 31 | * @see \Codeception\Module\Phiremock::expectARequestToRemoteServiceWithAResponse() 32 | */ 33 | public function expectARequestToRemoteServiceWithAResponse($expectation): void { 34 | $this->getScenario()->runStep(new \Codeception\Step\Action('expectARequestToRemoteServiceWithAResponse', func_get_args())); 35 | } 36 | 37 | 38 | /** 39 | * [!] Method is generated. Documentation taken from corresponding module. 40 | * 41 | @throws ClientExceptionInterface 42 | * @see \Codeception\Module\Phiremock::haveACleanSetupInRemoteService() 43 | */ 44 | public function haveACleanSetupInRemoteService(): void { 45 | $this->getScenario()->runStep(new \Codeception\Step\Action('haveACleanSetupInRemoteService', func_get_args())); 46 | } 47 | 48 | 49 | /** 50 | * [!] Method is generated. Documentation taken from corresponding module. 51 | * 52 | @throws ClientExceptionInterface 53 | * @see \Codeception\Module\Phiremock::dontExpectRequestsInRemoteService() 54 | */ 55 | public function dontExpectRequestsInRemoteService(): void { 56 | $this->getScenario()->runStep(new \Codeception\Step\Action('dontExpectRequestsInRemoteService', func_get_args())); 57 | } 58 | 59 | 60 | /** 61 | * [!] Method is generated. Documentation taken from corresponding module. 62 | * 63 | @throws ClientExceptionInterface 64 | * @see \Codeception\Module\Phiremock::haveCleanScenariosInRemoteService() 65 | */ 66 | public function haveCleanScenariosInRemoteService(): void { 67 | $this->getScenario()->runStep(new \Codeception\Step\Action('haveCleanScenariosInRemoteService', func_get_args())); 68 | } 69 | 70 | 71 | /** 72 | * [!] Method is generated. Documentation taken from corresponding module. 73 | * 74 | * @deprecated Name is confusing, sounds like an assertion 75 | * @throws ClientExceptionInterface 76 | * @see \Codeception\Module\Phiremock::didNotReceiveRequestsInRemoteService() 77 | */ 78 | public function didNotReceiveRequestsInRemoteService(): void { 79 | $this->getScenario()->runStep(new \Codeception\Step\Action('didNotReceiveRequestsInRemoteService', func_get_args())); 80 | } 81 | 82 | 83 | /** 84 | * [!] Method is generated. Documentation taken from corresponding module. 85 | * 86 | @throws ClientExceptionInterface 87 | * @see \Codeception\Module\Phiremock::dontHaveLoggedRequestsToRemoteService() 88 | */ 89 | public function dontHaveLoggedRequestsToRemoteService(): void { 90 | $this->getScenario()->runStep(new \Codeception\Step\Action('dontHaveLoggedRequestsToRemoteService', func_get_args())); 91 | } 92 | 93 | 94 | /** 95 | * [!] Method is generated. Documentation taken from corresponding module. 96 | * 97 | * @throws ClientExceptionInterface 98 | * @throws Exception 99 | * @see \Codeception\Module\Phiremock::seeRemoteServiceReceived() 100 | */ 101 | public function seeRemoteServiceReceived($times, $builder): void { 102 | $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeRemoteServiceReceived', func_get_args())); 103 | } 104 | /** 105 | * [!] Method is generated. Documentation taken from corresponding module. 106 | * 107 | * [!] Conditional Assertion: Test won't be stopped on fail 108 | * @throws ClientExceptionInterface 109 | * @throws Exception 110 | * @see \Codeception\Module\Phiremock::seeRemoteServiceReceived() 111 | */ 112 | public function canSeeRemoteServiceReceived($times, $builder): void { 113 | $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeRemoteServiceReceived', func_get_args())); 114 | } 115 | 116 | 117 | /** 118 | * [!] Method is generated. Documentation taken from corresponding module. 119 | * 120 | @throws ClientExceptionInterface 121 | * @see \Codeception\Module\Phiremock::grabRequestsMadeToRemoteService() 122 | */ 123 | public function grabRequestsMadeToRemoteService($builder): array { 124 | return $this->getScenario()->runStep(new \Codeception\Step\Action('grabRequestsMadeToRemoteService', func_get_args())); 125 | } 126 | 127 | 128 | /** 129 | * [!] Method is generated. Documentation taken from corresponding module. 130 | * 131 | @throws ClientExceptionInterface 132 | * @see \Codeception\Module\Phiremock::setScenarioState() 133 | */ 134 | public function setScenarioState($name, $state): void { 135 | $this->getScenario()->runStep(new \Codeception\Step\Action('setScenarioState', func_get_args())); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /tests/_support/_generated/UnitTesterActions.php: -------------------------------------------------------------------------------- 1 | expectException(MyException::class, function() { 25 | * $this->doSomethingBad(); 26 | * }); 27 | * 28 | * $I->expectException(new MyException(), function() { 29 | * $this->doSomethingBad(); 30 | * }); 31 | * ``` 32 | * If you want to check message or exception code, you can pass them with exception instance: 33 | * ```php 34 | * expectException(new MyException("Don't do bad things"), function() { 37 | * $this->doSomethingBad(); 38 | * }); 39 | * ``` 40 | * 41 | * @deprecated Use expectThrowable() instead 42 | * @param \Exception|string $exception 43 | * @param callable $callback 44 | * @see \Codeception\Module\Asserts::expectException() 45 | */ 46 | public function expectException($exception, $callback) { 47 | return $this->getScenario()->runStep(new \Codeception\Step\Action('expectException', func_get_args())); 48 | } 49 | 50 | 51 | /** 52 | * [!] Method is generated. Documentation taken from corresponding module. 53 | * 54 | * Handles and checks throwables (Exceptions/Errors) called inside the callback function. 55 | * Either throwable class name or throwable instance should be provided. 56 | * 57 | * ```php 58 | * expectThrowable(MyThrowable::class, function() { 60 | * $this->doSomethingBad(); 61 | * }); 62 | * 63 | * $I->expectThrowable(new MyException(), function() { 64 | * $this->doSomethingBad(); 65 | * }); 66 | * ``` 67 | * If you want to check message or throwable code, you can pass them with throwable instance: 68 | * ```php 69 | * expectThrowable(new MyError("Don't do bad things"), function() { 72 | * $this->doSomethingBad(); 73 | * }); 74 | * ``` 75 | * 76 | * @param \Throwable|string $throwable 77 | * @param callable $callback 78 | * @see \Codeception\Module\Asserts::expectThrowable() 79 | */ 80 | public function expectThrowable($throwable, $callback) { 81 | return $this->getScenario()->runStep(new \Codeception\Step\Action('expectThrowable', func_get_args())); 82 | } 83 | 84 | 85 | /** 86 | * [!] Method is generated. Documentation taken from corresponding module. 87 | * 88 | * Asserts that a file does not exist. 89 | * 90 | * @param string $filename 91 | * @param string $message 92 | * @see \Codeception\Module\AbstractAsserts::assertFileNotExists() 93 | */ 94 | public function assertFileNotExists($filename, $message = "") { 95 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotExists', func_get_args())); 96 | } 97 | 98 | 99 | /** 100 | * [!] Method is generated. Documentation taken from corresponding module. 101 | * 102 | * Asserts that a value is greater than or equal to another value. 103 | * 104 | * @param $expected 105 | * @param $actual 106 | * @param string $message 107 | * @see \Codeception\Module\AbstractAsserts::assertGreaterOrEquals() 108 | */ 109 | public function assertGreaterOrEquals($expected, $actual, $message = "") { 110 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args())); 111 | } 112 | 113 | 114 | /** 115 | * [!] Method is generated. Documentation taken from corresponding module. 116 | * 117 | * Asserts that a variable is empty. 118 | * 119 | * @param $actual 120 | * @param string $message 121 | * @see \Codeception\Module\AbstractAsserts::assertIsEmpty() 122 | */ 123 | public function assertIsEmpty($actual, $message = "") { 124 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args())); 125 | } 126 | 127 | 128 | /** 129 | * [!] Method is generated. Documentation taken from corresponding module. 130 | * 131 | * Asserts that a value is smaller than or equal to another value. 132 | * 133 | * @param $expected 134 | * @param $actual 135 | * @param string $message 136 | * @see \Codeception\Module\AbstractAsserts::assertLessOrEquals() 137 | */ 138 | public function assertLessOrEquals($expected, $actual, $message = "") { 139 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args())); 140 | } 141 | 142 | 143 | /** 144 | * [!] Method is generated. Documentation taken from corresponding module. 145 | * 146 | * Asserts that a string does not match a given regular expression. 147 | * 148 | * @param string $pattern 149 | * @param string $string 150 | * @param string $message 151 | * @see \Codeception\Module\AbstractAsserts::assertNotRegExp() 152 | */ 153 | public function assertNotRegExp($pattern, $string, $message = "") { 154 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotRegExp', func_get_args())); 155 | } 156 | 157 | 158 | /** 159 | * [!] Method is generated. Documentation taken from corresponding module. 160 | * 161 | * Asserts that a string matches a given regular expression. 162 | * 163 | * @param string $pattern 164 | * @param string $string 165 | * @param string $message 166 | * @see \Codeception\Module\AbstractAsserts::assertRegExp() 167 | */ 168 | public function assertRegExp($pattern, $string, $message = "") { 169 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertRegExp', func_get_args())); 170 | } 171 | 172 | 173 | /** 174 | * [!] Method is generated. Documentation taken from corresponding module. 175 | * 176 | * Evaluates a PHPUnit\Framework\Constraint matcher object. 177 | * 178 | * @param $value 179 | * @param Constraint $constraint 180 | * @param string $message 181 | * @see \Codeception\Module\AbstractAsserts::assertThatItsNot() 182 | */ 183 | public function assertThatItsNot($value, $constraint, $message = "") { 184 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertThatItsNot', func_get_args())); 185 | } 186 | 187 | 188 | /** 189 | * [!] Method is generated. Documentation taken from corresponding module. 190 | * 191 | * Asserts that an array has a specified key. 192 | * 193 | * @param int|string $key 194 | * @param array|ArrayAccess $array 195 | * @param string $message 196 | * @see \Codeception\Module\AbstractAsserts::assertArrayHasKey() 197 | */ 198 | public function assertArrayHasKey($key, $array, $message = "") { 199 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args())); 200 | } 201 | 202 | 203 | /** 204 | * [!] Method is generated. Documentation taken from corresponding module. 205 | * 206 | * Asserts that an array does not have a specified key. 207 | * 208 | * @param int|string $key 209 | * @param array|ArrayAccess $array 210 | * @param string $message 211 | * @see \Codeception\Module\AbstractAsserts::assertArrayNotHasKey() 212 | */ 213 | public function assertArrayNotHasKey($key, $array, $message = "") { 214 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args())); 215 | } 216 | 217 | 218 | /** 219 | * [!] Method is generated. Documentation taken from corresponding module. 220 | * 221 | * Asserts that a class has a specified attribute. 222 | * 223 | * @param string $attributeName 224 | * @param string $className 225 | * @param string $message 226 | * @see \Codeception\Module\AbstractAsserts::assertClassHasAttribute() 227 | */ 228 | public function assertClassHasAttribute($attributeName, $className, $message = "") { 229 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassHasAttribute', func_get_args())); 230 | } 231 | 232 | 233 | /** 234 | * [!] Method is generated. Documentation taken from corresponding module. 235 | * 236 | * Asserts that a class has a specified static attribute. 237 | * 238 | * @param string $attributeName 239 | * @param string $className 240 | * @param string $message 241 | * @see \Codeception\Module\AbstractAsserts::assertClassHasStaticAttribute() 242 | */ 243 | public function assertClassHasStaticAttribute($attributeName, $className, $message = "") { 244 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassHasStaticAttribute', func_get_args())); 245 | } 246 | 247 | 248 | /** 249 | * [!] Method is generated. Documentation taken from corresponding module. 250 | * 251 | * Asserts that a class does not have a specified attribute. 252 | * 253 | * @param string $attributeName 254 | * @param string $className 255 | * @param string $message 256 | * @see \Codeception\Module\AbstractAsserts::assertClassNotHasAttribute() 257 | */ 258 | public function assertClassNotHasAttribute($attributeName, $className, $message = "") { 259 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassNotHasAttribute', func_get_args())); 260 | } 261 | 262 | 263 | /** 264 | * [!] Method is generated. Documentation taken from corresponding module. 265 | * 266 | * Asserts that a class does not have a specified static attribute. 267 | * 268 | * @param string $attributeName 269 | * @param string $className 270 | * @param string $message 271 | * @see \Codeception\Module\AbstractAsserts::assertClassNotHasStaticAttribute() 272 | */ 273 | public function assertClassNotHasStaticAttribute($attributeName, $className, $message = "") { 274 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassNotHasStaticAttribute', func_get_args())); 275 | } 276 | 277 | 278 | /** 279 | * [!] Method is generated. Documentation taken from corresponding module. 280 | * 281 | * Asserts that a haystack contains a needle. 282 | * 283 | * @param $needle 284 | * @param $haystack 285 | * @param string $message 286 | * @see \Codeception\Module\AbstractAsserts::assertContains() 287 | */ 288 | public function assertContains($needle, $haystack, $message = "") { 289 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContains', func_get_args())); 290 | } 291 | 292 | 293 | /** 294 | * [!] Method is generated. Documentation taken from corresponding module. 295 | * 296 | * @param $needle 297 | * @param $haystack 298 | * @param string $message 299 | * @see \Codeception\Module\AbstractAsserts::assertContainsEquals() 300 | */ 301 | public function assertContainsEquals($needle, $haystack, $message = "") { 302 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsEquals', func_get_args())); 303 | } 304 | 305 | 306 | /** 307 | * [!] Method is generated. Documentation taken from corresponding module. 308 | * 309 | * Asserts that a haystack contains only values of a given type. 310 | * 311 | * @param string $type 312 | * @param $haystack 313 | * @param bool|null $isNativeType 314 | * @param string $message 315 | * @see \Codeception\Module\AbstractAsserts::assertContainsOnly() 316 | */ 317 | public function assertContainsOnly($type, $haystack, $isNativeType = NULL, $message = "") { 318 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsOnly', func_get_args())); 319 | } 320 | 321 | 322 | /** 323 | * [!] Method is generated. Documentation taken from corresponding module. 324 | * 325 | * Asserts that a haystack contains only instances of a given class name. 326 | * 327 | * @param string $className 328 | * @param $haystack 329 | * @param string $message 330 | * @see \Codeception\Module\AbstractAsserts::assertContainsOnlyInstancesOf() 331 | */ 332 | public function assertContainsOnlyInstancesOf($className, $haystack, $message = "") { 333 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsOnlyInstancesOf', func_get_args())); 334 | } 335 | 336 | 337 | /** 338 | * [!] Method is generated. Documentation taken from corresponding module. 339 | * 340 | * Asserts the number of elements of an array, Countable or Traversable. 341 | * 342 | * @param int $expectedCount 343 | * @param Countable|iterable $haystack 344 | * @param string $message 345 | * @see \Codeception\Module\AbstractAsserts::assertCount() 346 | */ 347 | public function assertCount($expectedCount, $haystack, $message = "") { 348 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertCount', func_get_args())); 349 | } 350 | 351 | 352 | /** 353 | * [!] Method is generated. Documentation taken from corresponding module. 354 | * 355 | * Asserts that a directory does not exist. 356 | * 357 | * @param string $directory 358 | * @param string $message 359 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryDoesNotExist() 360 | */ 361 | public function assertDirectoryDoesNotExist($directory, $message = "") { 362 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryDoesNotExist', func_get_args())); 363 | } 364 | 365 | 366 | /** 367 | * [!] Method is generated. Documentation taken from corresponding module. 368 | * 369 | * Asserts that a directory exists. 370 | * 371 | * @param string $directory 372 | * @param string $message 373 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryExists() 374 | */ 375 | public function assertDirectoryExists($directory, $message = "") { 376 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryExists', func_get_args())); 377 | } 378 | 379 | 380 | /** 381 | * [!] Method is generated. Documentation taken from corresponding module. 382 | * 383 | * Asserts that a directory exists and is not readable. 384 | * 385 | * @param string $directory 386 | * @param string $message 387 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsNotReadable() 388 | */ 389 | public function assertDirectoryIsNotReadable($directory, $message = "") { 390 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsNotReadable', func_get_args())); 391 | } 392 | 393 | 394 | /** 395 | * [!] Method is generated. Documentation taken from corresponding module. 396 | * 397 | * Asserts that a directory exists and is not writable. 398 | * 399 | * @param string $directory 400 | * @param string $message 401 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsNotWritable() 402 | */ 403 | public function assertDirectoryIsNotWritable($directory, $message = "") { 404 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsNotWritable', func_get_args())); 405 | } 406 | 407 | 408 | /** 409 | * [!] Method is generated. Documentation taken from corresponding module. 410 | * 411 | * Asserts that a directory exists and is readable. 412 | * 413 | * @param string $directory 414 | * @param string $message 415 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsReadable() 416 | */ 417 | public function assertDirectoryIsReadable($directory, $message = "") { 418 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsReadable', func_get_args())); 419 | } 420 | 421 | 422 | /** 423 | * [!] Method is generated. Documentation taken from corresponding module. 424 | * 425 | * Asserts that a directory exists and is writable. 426 | * 427 | * @param string $directory 428 | * @param string $message 429 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsWritable() 430 | */ 431 | public function assertDirectoryIsWritable($directory, $message = "") { 432 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsWritable', func_get_args())); 433 | } 434 | 435 | 436 | /** 437 | * [!] Method is generated. Documentation taken from corresponding module. 438 | * 439 | * Asserts that a string does not match a given regular expression. 440 | * 441 | * @param string $pattern 442 | * @param string $string 443 | * @param string $message 444 | * @see \Codeception\Module\AbstractAsserts::assertDoesNotMatchRegularExpression() 445 | */ 446 | public function assertDoesNotMatchRegularExpression($pattern, $string, $message = "") { 447 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDoesNotMatchRegularExpression', func_get_args())); 448 | } 449 | 450 | 451 | /** 452 | * [!] Method is generated. Documentation taken from corresponding module. 453 | * 454 | * Asserts that a variable is empty. 455 | * 456 | * @param $actual 457 | * @param string $message 458 | * @see \Codeception\Module\AbstractAsserts::assertEmpty() 459 | */ 460 | public function assertEmpty($actual, $message = "") { 461 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args())); 462 | } 463 | 464 | 465 | /** 466 | * [!] Method is generated. Documentation taken from corresponding module. 467 | * 468 | * Asserts that two variables are equal. 469 | * 470 | * @param $expected 471 | * @param $actual 472 | * @param string $message 473 | * @see \Codeception\Module\AbstractAsserts::assertEquals() 474 | */ 475 | public function assertEquals($expected, $actual, $message = "") { 476 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args())); 477 | } 478 | 479 | 480 | /** 481 | * [!] Method is generated. Documentation taken from corresponding module. 482 | * 483 | * Asserts that two variables are equal (canonicalizing). 484 | * 485 | * @param $expected 486 | * @param $actual 487 | * @param string $message 488 | * @see \Codeception\Module\AbstractAsserts::assertEqualsCanonicalizing() 489 | */ 490 | public function assertEqualsCanonicalizing($expected, $actual, $message = "") { 491 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsCanonicalizing', func_get_args())); 492 | } 493 | 494 | 495 | /** 496 | * [!] Method is generated. Documentation taken from corresponding module. 497 | * 498 | * Asserts that two variables are equal (ignoring case). 499 | * 500 | * @param $expected 501 | * @param $actual 502 | * @param string $message 503 | * @see \Codeception\Module\AbstractAsserts::assertEqualsIgnoringCase() 504 | */ 505 | public function assertEqualsIgnoringCase($expected, $actual, $message = "") { 506 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsIgnoringCase', func_get_args())); 507 | } 508 | 509 | 510 | /** 511 | * [!] Method is generated. Documentation taken from corresponding module. 512 | * 513 | * Asserts that two variables are equal (with delta). 514 | * 515 | * @param $expected 516 | * @param $actual 517 | * @param float $delta 518 | * @param string $message 519 | * @see \Codeception\Module\AbstractAsserts::assertEqualsWithDelta() 520 | */ 521 | public function assertEqualsWithDelta($expected, $actual, $delta, $message = "") { 522 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsWithDelta', func_get_args())); 523 | } 524 | 525 | 526 | /** 527 | * [!] Method is generated. Documentation taken from corresponding module. 528 | * 529 | * Asserts that a condition is false. 530 | * 531 | * @param $condition 532 | * @param string $message 533 | * @see \Codeception\Module\AbstractAsserts::assertFalse() 534 | */ 535 | public function assertFalse($condition, $message = "") { 536 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFalse', func_get_args())); 537 | } 538 | 539 | 540 | /** 541 | * [!] Method is generated. Documentation taken from corresponding module. 542 | * 543 | * Asserts that a file does not exist. 544 | * 545 | * @param string $filename 546 | * @param string $message 547 | * @see \Codeception\Module\AbstractAsserts::assertFileDoesNotExist() 548 | */ 549 | public function assertFileDoesNotExist($filename, $message = "") { 550 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileDoesNotExist', func_get_args())); 551 | } 552 | 553 | 554 | /** 555 | * [!] Method is generated. Documentation taken from corresponding module. 556 | * 557 | * Asserts that the contents of one file is equal to the contents of another file. 558 | * 559 | * @param string $expected 560 | * @param string $actual 561 | * @param string $message 562 | * @see \Codeception\Module\AbstractAsserts::assertFileEquals() 563 | */ 564 | public function assertFileEquals($expected, $actual, $message = "") { 565 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEquals', func_get_args())); 566 | } 567 | 568 | 569 | /** 570 | * [!] Method is generated. Documentation taken from corresponding module. 571 | * 572 | * Asserts that the contents of one file is equal to the contents of another file (canonicalizing). 573 | * 574 | * @param $expected 575 | * @param $actual 576 | * @param string $message 577 | * @see \Codeception\Module\AbstractAsserts::assertFileEqualsCanonicalizing() 578 | */ 579 | public function assertFileEqualsCanonicalizing($expected, $actual, $message = "") { 580 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEqualsCanonicalizing', func_get_args())); 581 | } 582 | 583 | 584 | /** 585 | * [!] Method is generated. Documentation taken from corresponding module. 586 | * 587 | * Asserts that the contents of one file is equal to the contents of another file (ignoring case). 588 | * 589 | * @param $expected 590 | * @param $actual 591 | * @param string $message 592 | * @see \Codeception\Module\AbstractAsserts::assertFileEqualsIgnoringCase() 593 | */ 594 | public function assertFileEqualsIgnoringCase($expected, $actual, $message = "") { 595 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEqualsIgnoringCase', func_get_args())); 596 | } 597 | 598 | 599 | /** 600 | * [!] Method is generated. Documentation taken from corresponding module. 601 | * 602 | * Asserts that a file exists. 603 | * 604 | * @param string $filename 605 | * @param string $message 606 | * @see \Codeception\Module\AbstractAsserts::assertFileExists() 607 | */ 608 | public function assertFileExists($filename, $message = "") { 609 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileExists', func_get_args())); 610 | } 611 | 612 | 613 | /** 614 | * [!] Method is generated. Documentation taken from corresponding module. 615 | * 616 | * Asserts that a file exists and is not readable. 617 | * 618 | * @param string $file 619 | * @param string $message 620 | * @see \Codeception\Module\AbstractAsserts::assertFileIsNotReadable() 621 | */ 622 | public function assertFileIsNotReadable($file, $message = "") { 623 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsNotReadable', func_get_args())); 624 | } 625 | 626 | 627 | /** 628 | * [!] Method is generated. Documentation taken from corresponding module. 629 | * 630 | * Asserts that a file exists and is not writable. 631 | * 632 | * @param string $file 633 | * @param string $message 634 | * @see \Codeception\Module\AbstractAsserts::assertFileIsNotWritable() 635 | */ 636 | public function assertFileIsNotWritable($file, $message = "") { 637 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsNotWritable', func_get_args())); 638 | } 639 | 640 | 641 | /** 642 | * [!] Method is generated. Documentation taken from corresponding module. 643 | * 644 | * Asserts that a file exists and is readable. 645 | * 646 | * @param string $file 647 | * @param string $message 648 | * @see \Codeception\Module\AbstractAsserts::assertFileIsReadable() 649 | */ 650 | public function assertFileIsReadable($file, $message = "") { 651 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsReadable', func_get_args())); 652 | } 653 | 654 | 655 | /** 656 | * [!] Method is generated. Documentation taken from corresponding module. 657 | * 658 | * Asserts that a file exists and is writable. 659 | * 660 | * @param string $file 661 | * @param string $message 662 | * @see \Codeception\Module\AbstractAsserts::assertFileIsWritable() 663 | */ 664 | public function assertFileIsWritable($file, $message = "") { 665 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsWritable', func_get_args())); 666 | } 667 | 668 | 669 | /** 670 | * [!] Method is generated. Documentation taken from corresponding module. 671 | * 672 | * Asserts that the contents of one file is not equal to the contents of another file. 673 | * 674 | * @param $expected 675 | * @param $actual 676 | * @param string $message 677 | * @see \Codeception\Module\AbstractAsserts::assertFileNotEquals() 678 | */ 679 | public function assertFileNotEquals($expected, $actual, $message = "") { 680 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEquals', func_get_args())); 681 | } 682 | 683 | 684 | /** 685 | * [!] Method is generated. Documentation taken from corresponding module. 686 | * 687 | * Asserts that the contents of one file is not equal to the contents of another file (canonicalizing). 688 | * 689 | * @param $expected 690 | * @param $actual 691 | * @param string $message 692 | * @see \Codeception\Module\AbstractAsserts::assertFileNotEqualsCanonicalizing() 693 | */ 694 | public function assertFileNotEqualsCanonicalizing($expected, $actual, $message = "") { 695 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEqualsCanonicalizing', func_get_args())); 696 | } 697 | 698 | 699 | /** 700 | * [!] Method is generated. Documentation taken from corresponding module. 701 | * 702 | * Asserts that the contents of one file is not equal to the contents of another file (ignoring case). 703 | * 704 | * @param $expected 705 | * @param $actual 706 | * @param string $message 707 | * @see \Codeception\Module\AbstractAsserts::assertFileNotEqualsIgnoringCase() 708 | */ 709 | public function assertFileNotEqualsIgnoringCase($expected, $actual, $message = "") { 710 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEqualsIgnoringCase', func_get_args())); 711 | } 712 | 713 | 714 | /** 715 | * [!] Method is generated. Documentation taken from corresponding module. 716 | * 717 | * Asserts that a variable is finite. 718 | * 719 | * @param $actual 720 | * @param string $message 721 | * @see \Codeception\Module\AbstractAsserts::assertFinite() 722 | */ 723 | public function assertFinite($actual, $message = "") { 724 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFinite', func_get_args())); 725 | } 726 | 727 | 728 | /** 729 | * [!] Method is generated. Documentation taken from corresponding module. 730 | * 731 | * Asserts that a value is greater than another value. 732 | * 733 | * @param $expected 734 | * @param $actual 735 | * @param string $message 736 | * @see \Codeception\Module\AbstractAsserts::assertGreaterThan() 737 | */ 738 | public function assertGreaterThan($expected, $actual, $message = "") { 739 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args())); 740 | } 741 | 742 | 743 | /** 744 | * [!] Method is generated. Documentation taken from corresponding module. 745 | * 746 | * Asserts that a value is greater than or equal to another value. 747 | * 748 | * @param $expected 749 | * @param $actual 750 | * @param string $message 751 | * @see \Codeception\Module\AbstractAsserts::assertGreaterThanOrEqual() 752 | */ 753 | public function assertGreaterThanOrEqual($expected, $actual, $message = "") { 754 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args())); 755 | } 756 | 757 | 758 | /** 759 | * [!] Method is generated. Documentation taken from corresponding module. 760 | * 761 | * Asserts that a variable is infinite. 762 | * 763 | * @param $actual 764 | * @param string $message 765 | * @see \Codeception\Module\AbstractAsserts::assertInfinite() 766 | */ 767 | public function assertInfinite($actual, $message = "") { 768 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInfinite', func_get_args())); 769 | } 770 | 771 | 772 | /** 773 | * [!] Method is generated. Documentation taken from corresponding module. 774 | * 775 | * Asserts that a variable is of a given type. 776 | * 777 | * @param $expected 778 | * @param $actual 779 | * @param string $message 780 | * @see \Codeception\Module\AbstractAsserts::assertInstanceOf() 781 | */ 782 | public function assertInstanceOf($expected, $actual, $message = "") { 783 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInstanceOf', func_get_args())); 784 | } 785 | 786 | 787 | /** 788 | * [!] Method is generated. Documentation taken from corresponding module. 789 | * 790 | * Asserts that a variable is of type array. 791 | * 792 | * @param $actual 793 | * @param string $message 794 | * @see \Codeception\Module\AbstractAsserts::assertIsArray() 795 | */ 796 | public function assertIsArray($actual, $message = "") { 797 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsArray', func_get_args())); 798 | } 799 | 800 | 801 | /** 802 | * [!] Method is generated. Documentation taken from corresponding module. 803 | * 804 | * Asserts that a variable is of type bool. 805 | * 806 | * @param $actual 807 | * @param string $message 808 | * @see \Codeception\Module\AbstractAsserts::assertIsBool() 809 | */ 810 | public function assertIsBool($actual, $message = "") { 811 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsBool', func_get_args())); 812 | } 813 | 814 | 815 | /** 816 | * [!] Method is generated. Documentation taken from corresponding module. 817 | * 818 | * Asserts that a variable is of type callable. 819 | * 820 | * @param $actual 821 | * @param string $message 822 | * @see \Codeception\Module\AbstractAsserts::assertIsCallable() 823 | */ 824 | public function assertIsCallable($actual, $message = "") { 825 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsCallable', func_get_args())); 826 | } 827 | 828 | 829 | /** 830 | * [!] Method is generated. Documentation taken from corresponding module. 831 | * 832 | * Asserts that a variable is of type resource and is closed. 833 | * 834 | * @param $actual 835 | * @param string $message 836 | * @see \Codeception\Module\AbstractAsserts::assertIsClosedResource() 837 | */ 838 | public function assertIsClosedResource($actual, $message = "") { 839 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsClosedResource', func_get_args())); 840 | } 841 | 842 | 843 | /** 844 | * [!] Method is generated. Documentation taken from corresponding module. 845 | * 846 | * Asserts that a variable is of type float. 847 | * 848 | * @param $actual 849 | * @param string $message 850 | * @see \Codeception\Module\AbstractAsserts::assertIsFloat() 851 | */ 852 | public function assertIsFloat($actual, $message = "") { 853 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsFloat', func_get_args())); 854 | } 855 | 856 | 857 | /** 858 | * [!] Method is generated. Documentation taken from corresponding module. 859 | * 860 | * Asserts that a variable is of type int. 861 | * 862 | * @param $actual 863 | * @param string $message 864 | * @see \Codeception\Module\AbstractAsserts::assertIsInt() 865 | */ 866 | public function assertIsInt($actual, $message = "") { 867 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsInt', func_get_args())); 868 | } 869 | 870 | 871 | /** 872 | * [!] Method is generated. Documentation taken from corresponding module. 873 | * 874 | * Asserts that a variable is of type iterable. 875 | * 876 | * @param $actual 877 | * @param string $message 878 | * @see \Codeception\Module\AbstractAsserts::assertIsIterable() 879 | */ 880 | public function assertIsIterable($actual, $message = "") { 881 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsIterable', func_get_args())); 882 | } 883 | 884 | 885 | /** 886 | * [!] Method is generated. Documentation taken from corresponding module. 887 | * 888 | * Asserts that a variable is not of type array. 889 | * 890 | * @param $actual 891 | * @param string $message 892 | * @see \Codeception\Module\AbstractAsserts::assertIsNotArray() 893 | */ 894 | public function assertIsNotArray($actual, $message = "") { 895 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotArray', func_get_args())); 896 | } 897 | 898 | 899 | /** 900 | * [!] Method is generated. Documentation taken from corresponding module. 901 | * 902 | * Asserts that a variable is not of type bool. 903 | * 904 | * @param $actual 905 | * @param string $message 906 | * @see \Codeception\Module\AbstractAsserts::assertIsNotBool() 907 | */ 908 | public function assertIsNotBool($actual, $message = "") { 909 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotBool', func_get_args())); 910 | } 911 | 912 | 913 | /** 914 | * [!] Method is generated. Documentation taken from corresponding module. 915 | * 916 | * Asserts that a variable is not of type callable. 917 | * 918 | * @param $actual 919 | * @param string $message 920 | * @see \Codeception\Module\AbstractAsserts::assertIsNotCallable() 921 | */ 922 | public function assertIsNotCallable($actual, $message = "") { 923 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotCallable', func_get_args())); 924 | } 925 | 926 | 927 | /** 928 | * [!] Method is generated. Documentation taken from corresponding module. 929 | * 930 | * Asserts that a variable is not of type resource. 931 | * 932 | * @param $actual 933 | * @param string $message 934 | * @see \Codeception\Module\AbstractAsserts::assertIsNotClosedResource() 935 | */ 936 | public function assertIsNotClosedResource($actual, $message = "") { 937 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotClosedResource', func_get_args())); 938 | } 939 | 940 | 941 | /** 942 | * [!] Method is generated. Documentation taken from corresponding module. 943 | * 944 | * Asserts that a variable is not of type float. 945 | * 946 | * @param $actual 947 | * @param string $message 948 | * @see \Codeception\Module\AbstractAsserts::assertIsNotFloat() 949 | */ 950 | public function assertIsNotFloat($actual, $message = "") { 951 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotFloat', func_get_args())); 952 | } 953 | 954 | 955 | /** 956 | * [!] Method is generated. Documentation taken from corresponding module. 957 | * 958 | * Asserts that a variable is not of type int. 959 | * 960 | * @param $actual 961 | * @param string $message 962 | * @see \Codeception\Module\AbstractAsserts::assertIsNotInt() 963 | */ 964 | public function assertIsNotInt($actual, $message = "") { 965 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotInt', func_get_args())); 966 | } 967 | 968 | 969 | /** 970 | * [!] Method is generated. Documentation taken from corresponding module. 971 | * 972 | * Asserts that a variable is not of type iterable. 973 | * 974 | * @param $actual 975 | * @param string $message 976 | * @see \Codeception\Module\AbstractAsserts::assertIsNotIterable() 977 | */ 978 | public function assertIsNotIterable($actual, $message = "") { 979 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotIterable', func_get_args())); 980 | } 981 | 982 | 983 | /** 984 | * [!] Method is generated. Documentation taken from corresponding module. 985 | * 986 | * Asserts that a variable is not of type numeric. 987 | * 988 | * @param $actual 989 | * @param string $message 990 | * @see \Codeception\Module\AbstractAsserts::assertIsNotNumeric() 991 | */ 992 | public function assertIsNotNumeric($actual, $message = "") { 993 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotNumeric', func_get_args())); 994 | } 995 | 996 | 997 | /** 998 | * [!] Method is generated. Documentation taken from corresponding module. 999 | * 1000 | * Asserts that a variable is not of type object. 1001 | * 1002 | * @param $actual 1003 | * @param string $message 1004 | * @see \Codeception\Module\AbstractAsserts::assertIsNotObject() 1005 | */ 1006 | public function assertIsNotObject($actual, $message = "") { 1007 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotObject', func_get_args())); 1008 | } 1009 | 1010 | 1011 | /** 1012 | * [!] Method is generated. Documentation taken from corresponding module. 1013 | * 1014 | * Asserts that a file/dir exists and is not readable. 1015 | * 1016 | * @param string $filename 1017 | * @param string $message 1018 | * @see \Codeception\Module\AbstractAsserts::assertIsNotReadable() 1019 | */ 1020 | public function assertIsNotReadable($filename, $message = "") { 1021 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotReadable', func_get_args())); 1022 | } 1023 | 1024 | 1025 | /** 1026 | * [!] Method is generated. Documentation taken from corresponding module. 1027 | * 1028 | * Asserts that a variable is not of type resource. 1029 | * 1030 | * @param $actual 1031 | * @param string $message 1032 | * @see \Codeception\Module\AbstractAsserts::assertIsNotResource() 1033 | */ 1034 | public function assertIsNotResource($actual, $message = "") { 1035 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotResource', func_get_args())); 1036 | } 1037 | 1038 | 1039 | /** 1040 | * [!] Method is generated. Documentation taken from corresponding module. 1041 | * 1042 | * Asserts that a variable is not of type scalar. 1043 | * 1044 | * @param $actual 1045 | * @param string $message 1046 | * @see \Codeception\Module\AbstractAsserts::assertIsNotScalar() 1047 | */ 1048 | public function assertIsNotScalar($actual, $message = "") { 1049 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotScalar', func_get_args())); 1050 | } 1051 | 1052 | 1053 | /** 1054 | * [!] Method is generated. Documentation taken from corresponding module. 1055 | * 1056 | * Asserts that a variable is not of type string. 1057 | * 1058 | * @param $actual 1059 | * @param string $message 1060 | * @see \Codeception\Module\AbstractAsserts::assertIsNotString() 1061 | */ 1062 | public function assertIsNotString($actual, $message = "") { 1063 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotString', func_get_args())); 1064 | } 1065 | 1066 | 1067 | /** 1068 | * [!] Method is generated. Documentation taken from corresponding module. 1069 | * 1070 | * Asserts that a file/dir exists and is not writable. 1071 | * 1072 | * @param $filename 1073 | * @param string $message 1074 | * @see \Codeception\Module\AbstractAsserts::assertIsNotWritable() 1075 | */ 1076 | public function assertIsNotWritable($filename, $message = "") { 1077 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotWritable', func_get_args())); 1078 | } 1079 | 1080 | 1081 | /** 1082 | * [!] Method is generated. Documentation taken from corresponding module. 1083 | * 1084 | * Asserts that a variable is of type numeric. 1085 | * 1086 | * @param $actual 1087 | * @param string $message 1088 | * @see \Codeception\Module\AbstractAsserts::assertIsNumeric() 1089 | */ 1090 | public function assertIsNumeric($actual, $message = "") { 1091 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNumeric', func_get_args())); 1092 | } 1093 | 1094 | 1095 | /** 1096 | * [!] Method is generated. Documentation taken from corresponding module. 1097 | * 1098 | * Asserts that a variable is of type object. 1099 | * 1100 | * @param $actual 1101 | * @param string $message 1102 | * @see \Codeception\Module\AbstractAsserts::assertIsObject() 1103 | */ 1104 | public function assertIsObject($actual, $message = "") { 1105 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsObject', func_get_args())); 1106 | } 1107 | 1108 | 1109 | /** 1110 | * [!] Method is generated. Documentation taken from corresponding module. 1111 | * 1112 | * Asserts that a file/dir is readable. 1113 | * 1114 | * @param $filename 1115 | * @param string $message 1116 | * @see \Codeception\Module\AbstractAsserts::assertIsReadable() 1117 | */ 1118 | public function assertIsReadable($filename, $message = "") { 1119 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsReadable', func_get_args())); 1120 | } 1121 | 1122 | 1123 | /** 1124 | * [!] Method is generated. Documentation taken from corresponding module. 1125 | * 1126 | * Asserts that a variable is of type resource. 1127 | * 1128 | * @param $actual 1129 | * @param string $message 1130 | * @see \Codeception\Module\AbstractAsserts::assertIsResource() 1131 | */ 1132 | public function assertIsResource($actual, $message = "") { 1133 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsResource', func_get_args())); 1134 | } 1135 | 1136 | 1137 | /** 1138 | * [!] Method is generated. Documentation taken from corresponding module. 1139 | * 1140 | * Asserts that a variable is of type scalar. 1141 | * 1142 | * @param $actual 1143 | * @param string $message 1144 | * @see \Codeception\Module\AbstractAsserts::assertIsScalar() 1145 | */ 1146 | public function assertIsScalar($actual, $message = "") { 1147 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsScalar', func_get_args())); 1148 | } 1149 | 1150 | 1151 | /** 1152 | * [!] Method is generated. Documentation taken from corresponding module. 1153 | * 1154 | * Asserts that a variable is of type string. 1155 | * 1156 | * @param $actual 1157 | * @param string $message 1158 | * @see \Codeception\Module\AbstractAsserts::assertIsString() 1159 | */ 1160 | public function assertIsString($actual, $message = "") { 1161 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsString', func_get_args())); 1162 | } 1163 | 1164 | 1165 | /** 1166 | * [!] Method is generated. Documentation taken from corresponding module. 1167 | * 1168 | * Asserts that a file/dir exists and is writable. 1169 | * 1170 | * @param $filename 1171 | * @param string $message 1172 | * @see \Codeception\Module\AbstractAsserts::assertIsWritable() 1173 | */ 1174 | public function assertIsWritable($filename, $message = "") { 1175 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsWritable', func_get_args())); 1176 | } 1177 | 1178 | 1179 | /** 1180 | * [!] Method is generated. Documentation taken from corresponding module. 1181 | * 1182 | * Asserts that a string is a valid JSON string. 1183 | * 1184 | * @param string $actualJson 1185 | * @param string $message 1186 | * @see \Codeception\Module\AbstractAsserts::assertJson() 1187 | */ 1188 | public function assertJson($actualJson, $message = "") { 1189 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJson', func_get_args())); 1190 | } 1191 | 1192 | 1193 | /** 1194 | * [!] Method is generated. Documentation taken from corresponding module. 1195 | * 1196 | * Asserts that two JSON files are equal. 1197 | * 1198 | * @param string $expectedFile 1199 | * @param string $actualFile 1200 | * @param string $message 1201 | * @see \Codeception\Module\AbstractAsserts::assertJsonFileEqualsJsonFile() 1202 | */ 1203 | public function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = "") { 1204 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonFileEqualsJsonFile', func_get_args())); 1205 | } 1206 | 1207 | 1208 | /** 1209 | * [!] Method is generated. Documentation taken from corresponding module. 1210 | * 1211 | * Asserts that two JSON files are not equal. 1212 | * 1213 | * @param string $expectedFile 1214 | * @param string $actualFile 1215 | * @param string $message 1216 | * @see \Codeception\Module\AbstractAsserts::assertJsonFileNotEqualsJsonFile() 1217 | */ 1218 | public function assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = "") { 1219 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonFileNotEqualsJsonFile', func_get_args())); 1220 | } 1221 | 1222 | 1223 | /** 1224 | * [!] Method is generated. Documentation taken from corresponding module. 1225 | * 1226 | * Asserts that the generated JSON encoded object and the content of the given file are equal. 1227 | * 1228 | * @param string $expectedFile 1229 | * @param string $actualJson 1230 | * @param string $message 1231 | * @see \Codeception\Module\AbstractAsserts::assertJsonStringEqualsJsonFile() 1232 | */ 1233 | public function assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = "") { 1234 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringEqualsJsonFile', func_get_args())); 1235 | } 1236 | 1237 | 1238 | /** 1239 | * [!] Method is generated. Documentation taken from corresponding module. 1240 | * 1241 | * Asserts that two given JSON encoded objects or arrays are equal. 1242 | * 1243 | * @param string $expectedJson 1244 | * @param string $actualJson 1245 | * @param string $message 1246 | * @see \Codeception\Module\AbstractAsserts::assertJsonStringEqualsJsonString() 1247 | */ 1248 | public function assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = "") { 1249 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringEqualsJsonString', func_get_args())); 1250 | } 1251 | 1252 | 1253 | /** 1254 | * [!] Method is generated. Documentation taken from corresponding module. 1255 | * 1256 | * Asserts that the generated JSON encoded object and the content of the given file are not equal. 1257 | * 1258 | * @param string $expectedFile 1259 | * @param string $actualJson 1260 | * @param string $message 1261 | * @see \Codeception\Module\AbstractAsserts::assertJsonStringNotEqualsJsonFile() 1262 | */ 1263 | public function assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = "") { 1264 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringNotEqualsJsonFile', func_get_args())); 1265 | } 1266 | 1267 | 1268 | /** 1269 | * [!] Method is generated. Documentation taken from corresponding module. 1270 | * 1271 | * Asserts that two given JSON encoded objects or arrays are not equal. 1272 | * 1273 | * @param string $expectedJson 1274 | * @param string $actualJson 1275 | * @param string $message 1276 | * @see \Codeception\Module\AbstractAsserts::assertJsonStringNotEqualsJsonString() 1277 | */ 1278 | public function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = "") { 1279 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringNotEqualsJsonString', func_get_args())); 1280 | } 1281 | 1282 | 1283 | /** 1284 | * [!] Method is generated. Documentation taken from corresponding module. 1285 | * 1286 | * Asserts that a value is smaller than another value. 1287 | * 1288 | * @param $expected 1289 | * @param $actual 1290 | * @param string $message 1291 | * @see \Codeception\Module\AbstractAsserts::assertLessThan() 1292 | */ 1293 | public function assertLessThan($expected, $actual, $message = "") { 1294 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThan', func_get_args())); 1295 | } 1296 | 1297 | 1298 | /** 1299 | * [!] Method is generated. Documentation taken from corresponding module. 1300 | * 1301 | * Asserts that a value is smaller than or equal to another value. 1302 | * 1303 | * @param $expected 1304 | * @param $actual 1305 | * @param string $message 1306 | * @see \Codeception\Module\AbstractAsserts::assertLessThanOrEqual() 1307 | */ 1308 | public function assertLessThanOrEqual($expected, $actual, $message = "") { 1309 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThanOrEqual', func_get_args())); 1310 | } 1311 | 1312 | 1313 | /** 1314 | * [!] Method is generated. Documentation taken from corresponding module. 1315 | * 1316 | * Asserts that a string matches a given regular expression. 1317 | * 1318 | * @param string $pattern 1319 | * @param string $string 1320 | * @param string $message 1321 | * @see \Codeception\Module\AbstractAsserts::assertMatchesRegularExpression() 1322 | */ 1323 | public function assertMatchesRegularExpression($pattern, $string, $message = "") { 1324 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertMatchesRegularExpression', func_get_args())); 1325 | } 1326 | 1327 | 1328 | /** 1329 | * [!] Method is generated. Documentation taken from corresponding module. 1330 | * 1331 | * Asserts that a variable is nan. 1332 | * 1333 | * @param $actual 1334 | * @param string $message 1335 | * @see \Codeception\Module\AbstractAsserts::assertNan() 1336 | */ 1337 | public function assertNan($actual, $message = "") { 1338 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNan', func_get_args())); 1339 | } 1340 | 1341 | 1342 | /** 1343 | * [!] Method is generated. Documentation taken from corresponding module. 1344 | * 1345 | * Asserts that a haystack does not contain a needle. 1346 | * 1347 | * @param $needle 1348 | * @param $haystack 1349 | * @param string $message 1350 | * @see \Codeception\Module\AbstractAsserts::assertNotContains() 1351 | */ 1352 | public function assertNotContains($needle, $haystack, $message = "") { 1353 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args())); 1354 | } 1355 | 1356 | 1357 | /** 1358 | * [!] Method is generated. Documentation taken from corresponding module. 1359 | * 1360 | * 1361 | * @see \Codeception\Module\AbstractAsserts::assertNotContainsEquals() 1362 | */ 1363 | public function assertNotContainsEquals($needle, $haystack, $message = "") { 1364 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContainsEquals', func_get_args())); 1365 | } 1366 | 1367 | 1368 | /** 1369 | * [!] Method is generated. Documentation taken from corresponding module. 1370 | * 1371 | * Asserts that a haystack does not contain only values of a given type. 1372 | * 1373 | * @param string $type 1374 | * @param $haystack 1375 | * @param bool|null $isNativeType 1376 | * @param string $message 1377 | * @see \Codeception\Module\AbstractAsserts::assertNotContainsOnly() 1378 | */ 1379 | public function assertNotContainsOnly($type, $haystack, $isNativeType = NULL, $message = "") { 1380 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContainsOnly', func_get_args())); 1381 | } 1382 | 1383 | 1384 | /** 1385 | * [!] Method is generated. Documentation taken from corresponding module. 1386 | * 1387 | * Asserts the number of elements of an array, Countable or Traversable. 1388 | * 1389 | * @param int $expectedCount 1390 | * @param Countable|iterable $haystack 1391 | * @param string $message 1392 | * @see \Codeception\Module\AbstractAsserts::assertNotCount() 1393 | */ 1394 | public function assertNotCount($expectedCount, $haystack, $message = "") { 1395 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotCount', func_get_args())); 1396 | } 1397 | 1398 | 1399 | /** 1400 | * [!] Method is generated. Documentation taken from corresponding module. 1401 | * 1402 | * Asserts that a variable is not empty. 1403 | * 1404 | * @param $actual 1405 | * @param string $message 1406 | * @see \Codeception\Module\AbstractAsserts::assertNotEmpty() 1407 | */ 1408 | public function assertNotEmpty($actual, $message = "") { 1409 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args())); 1410 | } 1411 | 1412 | 1413 | /** 1414 | * [!] Method is generated. Documentation taken from corresponding module. 1415 | * 1416 | * Asserts that two variables are not equal. 1417 | * 1418 | * @param $expected 1419 | * @param $actual 1420 | * @param string $message 1421 | * @see \Codeception\Module\AbstractAsserts::assertNotEquals() 1422 | */ 1423 | public function assertNotEquals($expected, $actual, $message = "") { 1424 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args())); 1425 | } 1426 | 1427 | 1428 | /** 1429 | * [!] Method is generated. Documentation taken from corresponding module. 1430 | * 1431 | * Asserts that two variables are not equal (canonicalizing). 1432 | * 1433 | * @param $expected 1434 | * @param $actual 1435 | * @param string $message 1436 | * @see \Codeception\Module\AbstractAsserts::assertNotEqualsCanonicalizing() 1437 | */ 1438 | public function assertNotEqualsCanonicalizing($expected, $actual, $message = "") { 1439 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEqualsCanonicalizing', func_get_args())); 1440 | } 1441 | 1442 | 1443 | /** 1444 | * [!] Method is generated. Documentation taken from corresponding module. 1445 | * 1446 | * Asserts that two variables are not equal (ignoring case). 1447 | * 1448 | * @param $expected 1449 | * @param $actual 1450 | * @param string $message 1451 | * @see \Codeception\Module\AbstractAsserts::assertNotEqualsIgnoringCase() 1452 | */ 1453 | public function assertNotEqualsIgnoringCase($expected, $actual, $message = "") { 1454 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEqualsIgnoringCase', func_get_args())); 1455 | } 1456 | 1457 | 1458 | /** 1459 | * [!] Method is generated. Documentation taken from corresponding module. 1460 | * 1461 | * Asserts that two variables are not equal (with delta). 1462 | * 1463 | * @param $expected 1464 | * @param $actual 1465 | * @param float $delta 1466 | * @param string $message 1467 | * @see \Codeception\Module\AbstractAsserts::assertNotEqualsWithDelta() 1468 | */ 1469 | public function assertNotEqualsWithDelta($expected, $actual, $delta, $message = "") { 1470 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEqualsWithDelta', func_get_args())); 1471 | } 1472 | 1473 | 1474 | /** 1475 | * [!] Method is generated. Documentation taken from corresponding module. 1476 | * 1477 | * Asserts that a condition is not false. 1478 | * 1479 | * @param $condition 1480 | * @param string $message 1481 | * @see \Codeception\Module\AbstractAsserts::assertNotFalse() 1482 | */ 1483 | public function assertNotFalse($condition, $message = "") { 1484 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotFalse', func_get_args())); 1485 | } 1486 | 1487 | 1488 | /** 1489 | * [!] Method is generated. Documentation taken from corresponding module. 1490 | * 1491 | * Asserts that a variable is not of a given type. 1492 | * 1493 | * @param $expected 1494 | * @param $actual 1495 | * @param string $message 1496 | * @see \Codeception\Module\AbstractAsserts::assertNotInstanceOf() 1497 | */ 1498 | public function assertNotInstanceOf($expected, $actual, $message = "") { 1499 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotInstanceOf', func_get_args())); 1500 | } 1501 | 1502 | 1503 | /** 1504 | * [!] Method is generated. Documentation taken from corresponding module. 1505 | * 1506 | * Asserts that a variable is not null. 1507 | * 1508 | * @param $actual 1509 | * @param string $message 1510 | * @see \Codeception\Module\AbstractAsserts::assertNotNull() 1511 | */ 1512 | public function assertNotNull($actual, $message = "") { 1513 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args())); 1514 | } 1515 | 1516 | 1517 | /** 1518 | * [!] Method is generated. Documentation taken from corresponding module. 1519 | * 1520 | * Asserts that two variables do not have the same type and value. 1521 | * 1522 | * @param $expected 1523 | * @param $actual 1524 | * @param string $message 1525 | * @see \Codeception\Module\AbstractAsserts::assertNotSame() 1526 | */ 1527 | public function assertNotSame($expected, $actual, $message = "") { 1528 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSame', func_get_args())); 1529 | } 1530 | 1531 | 1532 | /** 1533 | * [!] Method is generated. Documentation taken from corresponding module. 1534 | * 1535 | * Assert that the size of two arrays (or `Countable` or `Traversable` objects) is not the same. 1536 | * 1537 | * @param Countable|iterable $expected 1538 | * @param Countable|iterable $actual 1539 | * @param string $message 1540 | * @see \Codeception\Module\AbstractAsserts::assertNotSameSize() 1541 | */ 1542 | public function assertNotSameSize($expected, $actual, $message = "") { 1543 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSameSize', func_get_args())); 1544 | } 1545 | 1546 | 1547 | /** 1548 | * [!] Method is generated. Documentation taken from corresponding module. 1549 | * 1550 | * Asserts that a condition is not true. 1551 | * 1552 | * @param $condition 1553 | * @param string $message 1554 | * @see \Codeception\Module\AbstractAsserts::assertNotTrue() 1555 | */ 1556 | public function assertNotTrue($condition, $message = "") { 1557 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotTrue', func_get_args())); 1558 | } 1559 | 1560 | 1561 | /** 1562 | * [!] Method is generated. Documentation taken from corresponding module. 1563 | * 1564 | * Asserts that a variable is null. 1565 | * 1566 | * @param $actual 1567 | * @param string $message 1568 | * @see \Codeception\Module\AbstractAsserts::assertNull() 1569 | */ 1570 | public function assertNull($actual, $message = "") { 1571 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNull', func_get_args())); 1572 | } 1573 | 1574 | 1575 | /** 1576 | * [!] Method is generated. Documentation taken from corresponding module. 1577 | * 1578 | * Asserts that an object has a specified attribute. 1579 | * 1580 | * @param string $attributeName 1581 | * @param object $object 1582 | * @param string $message 1583 | * @see \Codeception\Module\AbstractAsserts::assertObjectHasAttribute() 1584 | */ 1585 | public function assertObjectHasAttribute($attributeName, $object, $message = "") { 1586 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertObjectHasAttribute', func_get_args())); 1587 | } 1588 | 1589 | 1590 | /** 1591 | * [!] Method is generated. Documentation taken from corresponding module. 1592 | * 1593 | * Asserts that an object does not have a specified attribute. 1594 | * 1595 | * @param string $attributeName 1596 | * @param object $object 1597 | * @param string $message 1598 | * @see \Codeception\Module\AbstractAsserts::assertObjectNotHasAttribute() 1599 | */ 1600 | public function assertObjectNotHasAttribute($attributeName, $object, $message = "") { 1601 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertObjectNotHasAttribute', func_get_args())); 1602 | } 1603 | 1604 | 1605 | /** 1606 | * [!] Method is generated. Documentation taken from corresponding module. 1607 | * 1608 | * Asserts that two variables have the same type and value. 1609 | * 1610 | * @param $expected 1611 | * @param $actual 1612 | * @param string $message 1613 | * @see \Codeception\Module\AbstractAsserts::assertSame() 1614 | */ 1615 | public function assertSame($expected, $actual, $message = "") { 1616 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSame', func_get_args())); 1617 | } 1618 | 1619 | 1620 | /** 1621 | * [!] Method is generated. Documentation taken from corresponding module. 1622 | * 1623 | * Assert that the size of two arrays (or `Countable` or `Traversable` objects) is the same. 1624 | * 1625 | * @param Countable|iterable $expected 1626 | * @param Countable|iterable $actual 1627 | * @param string $message 1628 | * @see \Codeception\Module\AbstractAsserts::assertSameSize() 1629 | */ 1630 | public function assertSameSize($expected, $actual, $message = "") { 1631 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSameSize', func_get_args())); 1632 | } 1633 | 1634 | 1635 | /** 1636 | * [!] Method is generated. Documentation taken from corresponding module. 1637 | * 1638 | * @param string $needle 1639 | * @param string $haystack 1640 | * @param string $message 1641 | * @see \Codeception\Module\AbstractAsserts::assertStringContainsString() 1642 | */ 1643 | public function assertStringContainsString($needle, $haystack, $message = "") { 1644 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringContainsString', func_get_args())); 1645 | } 1646 | 1647 | 1648 | /** 1649 | * [!] Method is generated. Documentation taken from corresponding module. 1650 | * 1651 | * 1652 | * @see \Codeception\Module\AbstractAsserts::assertStringContainsStringIgnoringCase() 1653 | */ 1654 | public function assertStringContainsStringIgnoringCase($needle, $haystack, $message = "") { 1655 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringContainsStringIgnoringCase', func_get_args())); 1656 | } 1657 | 1658 | 1659 | /** 1660 | * [!] Method is generated. Documentation taken from corresponding module. 1661 | * 1662 | * Asserts that a string ends not with a given suffix. 1663 | * 1664 | * @param string $suffix 1665 | * @param string $string 1666 | * @param string $message 1667 | * @see \Codeception\Module\AbstractAsserts::assertStringEndsNotWith() 1668 | */ 1669 | public function assertStringEndsNotWith($suffix, $string, $message = "") { 1670 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEndsNotWith', func_get_args())); 1671 | } 1672 | 1673 | 1674 | /** 1675 | * [!] Method is generated. Documentation taken from corresponding module. 1676 | * 1677 | * Asserts that a string ends with a given suffix. 1678 | * 1679 | * @param string $suffix 1680 | * @param string $string 1681 | * @param string $message 1682 | * @see \Codeception\Module\AbstractAsserts::assertStringEndsWith() 1683 | */ 1684 | public function assertStringEndsWith($suffix, $string, $message = "") { 1685 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEndsWith', func_get_args())); 1686 | } 1687 | 1688 | 1689 | /** 1690 | * [!] Method is generated. Documentation taken from corresponding module. 1691 | * 1692 | * Asserts that the contents of a string is equal to the contents of a file. 1693 | * 1694 | * @param string $expectedFile 1695 | * @param string $actualString 1696 | * @param string $message 1697 | * @see \Codeception\Module\AbstractAsserts::assertStringEqualsFile() 1698 | */ 1699 | public function assertStringEqualsFile($expectedFile, $actualString, $message = "") { 1700 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEqualsFile', func_get_args())); 1701 | } 1702 | 1703 | 1704 | /** 1705 | * [!] Method is generated. Documentation taken from corresponding module. 1706 | * 1707 | * Asserts that the contents of a string is equal to the contents of a file (canonicalizing). 1708 | * 1709 | * @param string $expectedFile 1710 | * @param string $actualString 1711 | * @param string $message 1712 | * @see \Codeception\Module\AbstractAsserts::assertStringEqualsFileCanonicalizing() 1713 | */ 1714 | public function assertStringEqualsFileCanonicalizing($expectedFile, $actualString, $message = "") { 1715 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEqualsFileCanonicalizing', func_get_args())); 1716 | } 1717 | 1718 | 1719 | /** 1720 | * [!] Method is generated. Documentation taken from corresponding module. 1721 | * 1722 | * Asserts that the contents of a string is equal to the contents of a file (ignoring case). 1723 | * 1724 | * @param string $expectedFile 1725 | * @param string $actualString 1726 | * @param string $message 1727 | * @see \Codeception\Module\AbstractAsserts::assertStringEqualsFileIgnoringCase() 1728 | */ 1729 | public function assertStringEqualsFileIgnoringCase($expectedFile, $actualString, $message = "") { 1730 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEqualsFileIgnoringCase', func_get_args())); 1731 | } 1732 | 1733 | 1734 | /** 1735 | * [!] Method is generated. Documentation taken from corresponding module. 1736 | * 1737 | * Asserts that a string matches a given format string. 1738 | * 1739 | * @param string $format 1740 | * @param string $string 1741 | * @param string $message 1742 | * @see \Codeception\Module\AbstractAsserts::assertStringMatchesFormat() 1743 | */ 1744 | public function assertStringMatchesFormat($format, $string, $message = "") { 1745 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringMatchesFormat', func_get_args())); 1746 | } 1747 | 1748 | 1749 | /** 1750 | * [!] Method is generated. Documentation taken from corresponding module. 1751 | * 1752 | * Asserts that a string matches a given format file. 1753 | * 1754 | * @param string $formatFile 1755 | * @param string $string 1756 | * @param string $message 1757 | * @see \Codeception\Module\AbstractAsserts::assertStringMatchesFormatFile() 1758 | */ 1759 | public function assertStringMatchesFormatFile($formatFile, $string, $message = "") { 1760 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringMatchesFormatFile', func_get_args())); 1761 | } 1762 | 1763 | 1764 | /** 1765 | * [!] Method is generated. Documentation taken from corresponding module. 1766 | * 1767 | * @param string $needle 1768 | * @param string $haystack 1769 | * @param string $message 1770 | * @see \Codeception\Module\AbstractAsserts::assertStringNotContainsString() 1771 | */ 1772 | public function assertStringNotContainsString($needle, $haystack, $message = "") { 1773 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotContainsString', func_get_args())); 1774 | } 1775 | 1776 | 1777 | /** 1778 | * [!] Method is generated. Documentation taken from corresponding module. 1779 | * 1780 | * @param string $needle 1781 | * @param string $haystack 1782 | * @param string $message 1783 | * @see \Codeception\Module\AbstractAsserts::assertStringNotContainsStringIgnoringCase() 1784 | */ 1785 | public function assertStringNotContainsStringIgnoringCase($needle, $haystack, $message = "") { 1786 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotContainsStringIgnoringCase', func_get_args())); 1787 | } 1788 | 1789 | 1790 | /** 1791 | * [!] Method is generated. Documentation taken from corresponding module. 1792 | * 1793 | * Asserts that the contents of a string is not equal to the contents of a file. 1794 | * 1795 | * @param string $expectedFile 1796 | * @param string $actualString 1797 | * @param string $message 1798 | * @see \Codeception\Module\AbstractAsserts::assertStringNotEqualsFile() 1799 | */ 1800 | public function assertStringNotEqualsFile($expectedFile, $actualString, $message = "") { 1801 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotEqualsFile', func_get_args())); 1802 | } 1803 | 1804 | 1805 | /** 1806 | * [!] Method is generated. Documentation taken from corresponding module. 1807 | * 1808 | * Asserts that the contents of a string is not equal to the contents of a file (canonicalizing). 1809 | * @param string $expectedFile 1810 | * @param string $actualString 1811 | * @param string $message 1812 | * @see \Codeception\Module\AbstractAsserts::assertStringNotEqualsFileCanonicalizing() 1813 | */ 1814 | public function assertStringNotEqualsFileCanonicalizing($expectedFile, $actualString, $message = "") { 1815 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotEqualsFileCanonicalizing', func_get_args())); 1816 | } 1817 | 1818 | 1819 | /** 1820 | * [!] Method is generated. Documentation taken from corresponding module. 1821 | * 1822 | * Asserts that the contents of a string is not equal to the contents of a file (ignoring case). 1823 | * 1824 | * @param string $expectedFile 1825 | * @param string $actualString 1826 | * @param string $message 1827 | * @see \Codeception\Module\AbstractAsserts::assertStringNotEqualsFileIgnoringCase() 1828 | */ 1829 | public function assertStringNotEqualsFileIgnoringCase($expectedFile, $actualString, $message = "") { 1830 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotEqualsFileIgnoringCase', func_get_args())); 1831 | } 1832 | 1833 | 1834 | /** 1835 | * [!] Method is generated. Documentation taken from corresponding module. 1836 | * 1837 | * Asserts that a string does not match a given format string. 1838 | * 1839 | * @param string $format 1840 | * @param string $string 1841 | * @param string $message 1842 | * @see \Codeception\Module\AbstractAsserts::assertStringNotMatchesFormat() 1843 | */ 1844 | public function assertStringNotMatchesFormat($format, $string, $message = "") { 1845 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotMatchesFormat', func_get_args())); 1846 | } 1847 | 1848 | 1849 | /** 1850 | * [!] Method is generated. Documentation taken from corresponding module. 1851 | * 1852 | * Asserts that a string does not match a given format string. 1853 | * 1854 | * @param string $formatFile 1855 | * @param string $string 1856 | * @param string $message 1857 | * @see \Codeception\Module\AbstractAsserts::assertStringNotMatchesFormatFile() 1858 | */ 1859 | public function assertStringNotMatchesFormatFile($formatFile, $string, $message = "") { 1860 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotMatchesFormatFile', func_get_args())); 1861 | } 1862 | 1863 | 1864 | /** 1865 | * [!] Method is generated. Documentation taken from corresponding module. 1866 | * 1867 | * Asserts that a string starts not with a given prefix. 1868 | * 1869 | * @param string $prefix 1870 | * @param string $string 1871 | * @param string $message 1872 | * @see \Codeception\Module\AbstractAsserts::assertStringStartsNotWith() 1873 | */ 1874 | public function assertStringStartsNotWith($prefix, $string, $message = "") { 1875 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsNotWith', func_get_args())); 1876 | } 1877 | 1878 | 1879 | /** 1880 | * [!] Method is generated. Documentation taken from corresponding module. 1881 | * 1882 | * Asserts that a string starts with a given prefix. 1883 | * 1884 | * @param string $prefix 1885 | * @param string $string 1886 | * @param string $message 1887 | * @see \Codeception\Module\AbstractAsserts::assertStringStartsWith() 1888 | */ 1889 | public function assertStringStartsWith($prefix, $string, $message = "") { 1890 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsWith', func_get_args())); 1891 | } 1892 | 1893 | 1894 | /** 1895 | * [!] Method is generated. Documentation taken from corresponding module. 1896 | * 1897 | * Evaluates a PHPUnit\Framework\Constraint matcher object. 1898 | * 1899 | * @param $value 1900 | * @param Constraint $constraint 1901 | * @param string $message 1902 | * @see \Codeception\Module\AbstractAsserts::assertThat() 1903 | */ 1904 | public function assertThat($value, $constraint, $message = "") { 1905 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertThat', func_get_args())); 1906 | } 1907 | 1908 | 1909 | /** 1910 | * [!] Method is generated. Documentation taken from corresponding module. 1911 | * 1912 | * Asserts that a condition is true. 1913 | * 1914 | * @param $condition 1915 | * @param string $message 1916 | * @see \Codeception\Module\AbstractAsserts::assertTrue() 1917 | */ 1918 | public function assertTrue($condition, $message = "") { 1919 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertTrue', func_get_args())); 1920 | } 1921 | 1922 | 1923 | /** 1924 | * [!] Method is generated. Documentation taken from corresponding module. 1925 | * 1926 | * Asserts that two XML files are equal. 1927 | * 1928 | * @param string $expectedFile 1929 | * @param string $actualFile 1930 | * @param string $message 1931 | * @see \Codeception\Module\AbstractAsserts::assertXmlFileEqualsXmlFile() 1932 | */ 1933 | public function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = "") { 1934 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlFileEqualsXmlFile', func_get_args())); 1935 | } 1936 | 1937 | 1938 | /** 1939 | * [!] Method is generated. Documentation taken from corresponding module. 1940 | * 1941 | * Asserts that two XML files are not equal. 1942 | * 1943 | * @param string $expectedFile 1944 | * @param string $actualFile 1945 | * @param string $message 1946 | * @see \Codeception\Module\AbstractAsserts::assertXmlFileNotEqualsXmlFile() 1947 | */ 1948 | public function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = "") { 1949 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlFileNotEqualsXmlFile', func_get_args())); 1950 | } 1951 | 1952 | 1953 | /** 1954 | * [!] Method is generated. Documentation taken from corresponding module. 1955 | * 1956 | * Asserts that two XML documents are equal. 1957 | * 1958 | * @param string $expectedFile 1959 | * @param DOMDocument|string $actualXml 1960 | * @param string $message 1961 | * @see \Codeception\Module\AbstractAsserts::assertXmlStringEqualsXmlFile() 1962 | */ 1963 | public function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = "") { 1964 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringEqualsXmlFile', func_get_args())); 1965 | } 1966 | 1967 | 1968 | /** 1969 | * [!] Method is generated. Documentation taken from corresponding module. 1970 | * 1971 | * Asserts that two XML documents are equal. 1972 | * 1973 | * @param DOMDocument|string $expectedXml 1974 | * @param DOMDocument|string $actualXml 1975 | * @param string $message 1976 | * @see \Codeception\Module\AbstractAsserts::assertXmlStringEqualsXmlString() 1977 | */ 1978 | public function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = "") { 1979 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringEqualsXmlString', func_get_args())); 1980 | } 1981 | 1982 | 1983 | /** 1984 | * [!] Method is generated. Documentation taken from corresponding module. 1985 | * 1986 | * Asserts that two XML documents are not equal. 1987 | * 1988 | * @param string $expectedFile 1989 | * @param DOMDocument|string $actualXml 1990 | * @param string $message 1991 | * @see \Codeception\Module\AbstractAsserts::assertXmlStringNotEqualsXmlFile() 1992 | */ 1993 | public function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = "") { 1994 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringNotEqualsXmlFile', func_get_args())); 1995 | } 1996 | 1997 | 1998 | /** 1999 | * [!] Method is generated. Documentation taken from corresponding module. 2000 | * 2001 | * Asserts that two XML documents are not equal. 2002 | * 2003 | * @param DOMDocument|string $expectedXml 2004 | * @param DOMDocument|string $actualXml 2005 | * @param string $message 2006 | * @see \Codeception\Module\AbstractAsserts::assertXmlStringNotEqualsXmlString() 2007 | */ 2008 | public function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = "") { 2009 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringNotEqualsXmlString', func_get_args())); 2010 | } 2011 | 2012 | 2013 | /** 2014 | * [!] Method is generated. Documentation taken from corresponding module. 2015 | * 2016 | * Fails a test with the given message. 2017 | * 2018 | * @param string $message 2019 | * @see \Codeception\Module\AbstractAsserts::fail() 2020 | */ 2021 | public function fail($message = "") { 2022 | return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args())); 2023 | } 2024 | 2025 | 2026 | /** 2027 | * [!] Method is generated. Documentation taken from corresponding module. 2028 | * 2029 | * Mark the test as incomplete. 2030 | * 2031 | * @param string $message 2032 | * @see \Codeception\Module\AbstractAsserts::markTestIncomplete() 2033 | */ 2034 | public function markTestIncomplete($message = "") { 2035 | return $this->getScenario()->runStep(new \Codeception\Step\Action('markTestIncomplete', func_get_args())); 2036 | } 2037 | 2038 | 2039 | /** 2040 | * [!] Method is generated. Documentation taken from corresponding module. 2041 | * 2042 | * Mark the test as skipped. 2043 | * 2044 | * @param string $message 2045 | * @see \Codeception\Module\AbstractAsserts::markTestSkipped() 2046 | */ 2047 | public function markTestSkipped($message = "") { 2048 | return $this->getScenario()->runStep(new \Codeception\Step\Action('markTestSkipped', func_get_args())); 2049 | } 2050 | 2051 | 2052 | /** 2053 | * [!] Method is generated. Documentation taken from corresponding module. 2054 | * 2055 | @throws ModuleException 2056 | * @see \Codeception\Module\Phiremock::takeConnection() 2057 | */ 2058 | public function takeConnection($name): \Codeception\Module\Phiremock { 2059 | return $this->getScenario()->runStep(new \Codeception\Step\Action('takeConnection', func_get_args())); 2060 | } 2061 | 2062 | 2063 | /** 2064 | * [!] Method is generated. Documentation taken from corresponding module. 2065 | * 2066 | @throws ClientExceptionInterface 2067 | * @see \Codeception\Module\Phiremock::expectARequestToRemoteServiceWithAResponse() 2068 | */ 2069 | public function expectARequestToRemoteServiceWithAResponse($expectation): void { 2070 | $this->getScenario()->runStep(new \Codeception\Step\Action('expectARequestToRemoteServiceWithAResponse', func_get_args())); 2071 | } 2072 | 2073 | 2074 | /** 2075 | * [!] Method is generated. Documentation taken from corresponding module. 2076 | * 2077 | @throws ClientExceptionInterface 2078 | * @see \Codeception\Module\Phiremock::haveACleanSetupInRemoteService() 2079 | */ 2080 | public function haveACleanSetupInRemoteService(): void { 2081 | $this->getScenario()->runStep(new \Codeception\Step\Action('haveACleanSetupInRemoteService', func_get_args())); 2082 | } 2083 | 2084 | 2085 | /** 2086 | * [!] Method is generated. Documentation taken from corresponding module. 2087 | * 2088 | @throws ClientExceptionInterface 2089 | * @see \Codeception\Module\Phiremock::dontExpectRequestsInRemoteService() 2090 | */ 2091 | public function dontExpectRequestsInRemoteService(): void { 2092 | $this->getScenario()->runStep(new \Codeception\Step\Action('dontExpectRequestsInRemoteService', func_get_args())); 2093 | } 2094 | 2095 | 2096 | /** 2097 | * [!] Method is generated. Documentation taken from corresponding module. 2098 | * 2099 | @throws ClientExceptionInterface 2100 | * @see \Codeception\Module\Phiremock::haveCleanScenariosInRemoteService() 2101 | */ 2102 | public function haveCleanScenariosInRemoteService(): void { 2103 | $this->getScenario()->runStep(new \Codeception\Step\Action('haveCleanScenariosInRemoteService', func_get_args())); 2104 | } 2105 | 2106 | 2107 | /** 2108 | * [!] Method is generated. Documentation taken from corresponding module. 2109 | * 2110 | * @deprecated Name is confusing, sounds like an assertion 2111 | * @throws ClientExceptionInterface 2112 | * @see \Codeception\Module\Phiremock::didNotReceiveRequestsInRemoteService() 2113 | */ 2114 | public function didNotReceiveRequestsInRemoteService(): void { 2115 | $this->getScenario()->runStep(new \Codeception\Step\Action('didNotReceiveRequestsInRemoteService', func_get_args())); 2116 | } 2117 | 2118 | 2119 | /** 2120 | * [!] Method is generated. Documentation taken from corresponding module. 2121 | * 2122 | @throws ClientExceptionInterface 2123 | * @see \Codeception\Module\Phiremock::dontHaveLoggedRequestsToRemoteService() 2124 | */ 2125 | public function dontHaveLoggedRequestsToRemoteService(): void { 2126 | $this->getScenario()->runStep(new \Codeception\Step\Action('dontHaveLoggedRequestsToRemoteService', func_get_args())); 2127 | } 2128 | 2129 | 2130 | /** 2131 | * [!] Method is generated. Documentation taken from corresponding module. 2132 | * 2133 | * @throws ClientExceptionInterface 2134 | * @throws Exception 2135 | * @see \Codeception\Module\Phiremock::seeRemoteServiceReceived() 2136 | */ 2137 | public function seeRemoteServiceReceived($times, $builder): void { 2138 | $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeRemoteServiceReceived', func_get_args())); 2139 | } 2140 | /** 2141 | * [!] Method is generated. Documentation taken from corresponding module. 2142 | * 2143 | * [!] Conditional Assertion: Test won't be stopped on fail 2144 | * @throws ClientExceptionInterface 2145 | * @throws Exception 2146 | * @see \Codeception\Module\Phiremock::seeRemoteServiceReceived() 2147 | */ 2148 | public function canSeeRemoteServiceReceived($times, $builder): void { 2149 | $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeRemoteServiceReceived', func_get_args())); 2150 | } 2151 | 2152 | 2153 | /** 2154 | * [!] Method is generated. Documentation taken from corresponding module. 2155 | * 2156 | @throws ClientExceptionInterface 2157 | * @see \Codeception\Module\Phiremock::grabRequestsMadeToRemoteService() 2158 | */ 2159 | public function grabRequestsMadeToRemoteService($builder): array { 2160 | return $this->getScenario()->runStep(new \Codeception\Step\Action('grabRequestsMadeToRemoteService', func_get_args())); 2161 | } 2162 | 2163 | 2164 | /** 2165 | * [!] Method is generated. Documentation taken from corresponding module. 2166 | * 2167 | @throws ClientExceptionInterface 2168 | * @see \Codeception\Module\Phiremock::setScenarioState() 2169 | */ 2170 | public function setScenarioState($name, $state): void { 2171 | $this->getScenario()->runStep(new \Codeception\Step\Action('setScenarioState', func_get_args())); 2172 | } 2173 | } 2174 | -------------------------------------------------------------------------------- /tests/acceptance.suite.yml: -------------------------------------------------------------------------------- 1 | # Codeception Test Suite Configuration 2 | # 3 | # Suite for acceptance tests. 4 | # Perform tests in browser using the WebDriver or PhpBrowser. 5 | # If you need both WebDriver and PHPBrowser tests - create a separate suite. 6 | 7 | class_name: AcceptanceTester 8 | modules: 9 | enabled: 10 | - \Helper\Acceptance 11 | -------------------------------------------------------------------------------- /tests/acceptance/_bootstrap.php: -------------------------------------------------------------------------------- 1 | haveACleanSetupInRemoteService(); 37 | 38 | //Init curl 39 | $this->_curl = new linslin\yii2\curl\Curl(); 40 | } 41 | 42 | 43 | 44 | /** 45 | * Simple HTTP ok 46 | * @param FunctionalTester $I 47 | * @throws Exception 48 | */ 49 | public function simpleHttpOkTest(\FunctionalTester $I) 50 | { 51 | $I->expectARequestToRemoteServiceWithAResponse( 52 | Phiremock::on( 53 | A::getRequest()->andUrl(Is::equalTo('/test/httpStatus/200')) 54 | )->then( 55 | Respond::withStatusCode(200) 56 | ) 57 | ); 58 | 59 | $this->_curl->get($this->_endPoint . '/test/httpStatus/200'); 60 | $I->assertEquals($this->_curl->responseCode, 200); 61 | } 62 | 63 | 64 | /** 65 | * Try set params to send with get request 66 | * @param FunctionalTester $I 67 | * @throws Exception 68 | */ 69 | public function setGetParamsTest(\FunctionalTester $I) 70 | { 71 | //Init 72 | $this->_curl->reset(); 73 | $params = [ 74 | 'key' => 'value', 75 | 'secondKey' => 'secondValue' 76 | ]; 77 | 78 | $I->expectARequestToRemoteServiceWithAResponse( 79 | Phiremock::on( 80 | A::getRequest()->andUrl(Is::equalTo('/test/params/get?' . http_build_query($params))) 81 | )->then( 82 | Respond::withStatusCode(200) 83 | ) 84 | ); 85 | 86 | $this->_curl->setGetParams($params) 87 | ->get($this->_endPoint . '/test/params/get'); 88 | 89 | $I->assertEquals($this->_curl->responseCode, 200); 90 | $I->assertEquals($this->_curl->getUrl(), $this->_endPoint . '/test/params/get?' . http_build_query($params)); 91 | } 92 | 93 | 94 | /** 95 | * Try set post to send with post request 96 | * @param FunctionalTester $I 97 | * @throws Exception 98 | */ 99 | public function setPostParamsTest(\FunctionalTester $I) 100 | { 101 | //Init 102 | $this->_curl->reset(); 103 | $params = [ 104 | 'key' => 'value', 105 | 'secondKey' => 'secondValue' 106 | ]; 107 | 108 | 109 | $I->expectARequestToRemoteServiceWithAResponse( 110 | $expectation = Phiremock::on( 111 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 112 | ->andBody(Is::equalTo(http_build_query($params))) 113 | ->andHeader('Content-Type', Is::equalTo('application/x-www-form-urlencoded')) 114 | )->then( 115 | Respond::withStatusCode(200) 116 | ) 117 | ); 118 | 119 | $this->_curl->setPostParams($params) 120 | ->post($this->_endPoint . '/test/params/post'); 121 | $I->assertEquals($this->_curl->responseCode, 200); 122 | } 123 | 124 | 125 | /** 126 | * Try set post to send with post request 127 | * @param FunctionalTester $I 128 | * @throws Exception 129 | */ 130 | public function setPostParamsOptionTest(\FunctionalTester $I) 131 | { 132 | //Init 133 | $this->_curl->reset(); 134 | $params = [ 135 | 'key' => 'value', 136 | 'secondKey' => 'secondValue' 137 | ]; 138 | 139 | 140 | $I->expectARequestToRemoteServiceWithAResponse( 141 | $expectation = Phiremock::on( 142 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 143 | ->andBody(Is::equalTo(http_build_query($params))) 144 | ->andHeader('Content-Type', Is::equalTo('application/x-www-form-urlencoded')) 145 | )->then( 146 | Respond::withStatusCode(200) 147 | ) 148 | ); 149 | 150 | $this->_curl->setOption( 151 | CURLOPT_POSTFIELDS, 152 | http_build_query($params)) 153 | ->post($this->_endPoint . '/test/params/post'); 154 | $I->assertEquals($this->_curl->responseCode, 200); 155 | } 156 | 157 | 158 | 159 | /** 160 | * Try set post param with header modification 161 | * @param FunctionalTester $I 162 | * @throws Exception 163 | */ 164 | public function setPostParamsWithHeaderTest(\FunctionalTester $I) 165 | { 166 | //Init 167 | $this->_curl->reset(); 168 | $params = [ 169 | 'key' => 'value', 170 | 'secondKey' => 'secondValue' 171 | ]; 172 | 173 | $I->expectARequestToRemoteServiceWithAResponse( 174 | $expectation = Phiremock::on( 175 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 176 | ->andBody(Is::equalTo(http_build_query($params))) 177 | ->andHeader('Content-Type', Is::equalTo('application/json')) 178 | )->then( 179 | Respond::withStatusCode(200) 180 | ) 181 | ); 182 | 183 | $this->_curl->setPostParams($params) 184 | ->setHeaders([ 185 | 'Content-Type' => 'application/json' 186 | ]) 187 | ->post($this->_endPoint . '/test/params/post'); 188 | 189 | $I->assertEquals($this->_curl->responseCode, 200); 190 | } 191 | 192 | 193 | /** 194 | * Post JSON data test 195 | * @param FunctionalTester $I 196 | * @throws Exception 197 | */ 198 | public function postJsonTest(\FunctionalTester $I) 199 | { 200 | //Init 201 | $this->_curl->reset(); 202 | $params = [ 203 | 'key' => 'value', 204 | 'secondKey' => 'secondValue' 205 | ]; 206 | 207 | $I->expectARequestToRemoteServiceWithAResponse( 208 | $expectation = Phiremock::on( 209 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 210 | ->andBody(Is::equalTo(json_encode($params))) 211 | ->andHeader('content-type', Is::equalTo('application/json')) 212 | )->then( 213 | Respond::withStatusCode(200) 214 | ->andBody('{"id": 1, "description": "I am a resource"}') 215 | ) 216 | ); 217 | 218 | $this->_curl->setRequestBody(json_encode($params)) 219 | ->setHeaders([ 220 | 'content-type' => 'application/json', 221 | 'content-length' => strlen(json_encode($params)) 222 | ]) 223 | ->post($this->_endPoint . '/test/params/post'); 224 | 225 | $I->assertEquals($this->_curl->responseCode, 200); 226 | } 227 | 228 | 229 | /** 230 | * Get JSON response test 231 | * @param FunctionalTester $I 232 | * @throws Exception 233 | */ 234 | public function getWithDecodedJsonResponseTest(\FunctionalTester $I) 235 | { 236 | //Init 237 | $this->_curl->reset(); 238 | 239 | $I->expectARequestToRemoteServiceWithAResponse( 240 | $expectation = Phiremock::on( 241 | A::getRequest()->andUrl(Is::equalTo('/test/params/get/json')) 242 | )->then( 243 | Respond::withStatusCode(200) 244 | ->andBody('{"id": 1, "description": "I am a resource"}') 245 | ) 246 | ); 247 | 248 | $jsonResponse = $this->_curl->get($this->_endPoint . '/test/params/get/json', false); 249 | $I->assertEquals($this->_curl->responseCode, 200); 250 | $I->assertArrayHasKey('id', $jsonResponse); 251 | $I->assertArrayHasKey('description', $jsonResponse); 252 | $I->assertEquals($jsonResponse['id'], 1); 253 | $I->assertEquals($jsonResponse['description'], 'I am a resource'); 254 | } 255 | 256 | 257 | /** 258 | * Get JSON response test 259 | * @param FunctionalTester $I 260 | * @throws Exception 261 | */ 262 | public function getWithRawJsonResponseTest(\FunctionalTester $I) 263 | { 264 | //Init 265 | $this->_curl->reset(); 266 | 267 | $I->expectARequestToRemoteServiceWithAResponse( 268 | $expectation = Phiremock::on( 269 | A::getRequest()->andUrl(Is::equalTo('/test/params/get/json')) 270 | )->then( 271 | Respond::withStatusCode(200) 272 | ->andBody('{"id": 1, "description": "I am a resource"}') 273 | ) 274 | ); 275 | 276 | $rawResponse = $this->_curl->get($this->_endPoint . '/test/params/get/json', true); 277 | $I->assertEquals($this->_curl->responseCode, 200); 278 | $I->assertEquals($rawResponse, '{"id": 1, "description": "I am a resource"}'); 279 | } 280 | 281 | 282 | /** 283 | * Get header params with special header separators in values 284 | * @issue https://github.com/linslin/Yii2-Curl/issues/59 285 | * 286 | * @param FunctionalTester $I 287 | * @throws Exception 288 | */ 289 | public function getHeaderParamWithSpecialHeaderSeparatorInValue(\FunctionalTester $I) 290 | { 291 | //Init 292 | $this->_curl->reset(); 293 | 294 | $I->expectARequestToRemoteServiceWithAResponse( 295 | 296 | Phiremock::on( 297 | A::getRequest()->andUrl(Is::equalTo('/test/header')) 298 | )->then( 299 | Respond::withStatusCode(200) 300 | ->andHeader('param', 'value') 301 | ->andHeader('location', 'http://somelocation/') 302 | ) 303 | ); 304 | 305 | $this->_curl->get($this->_endPoint . '/test/header'); 306 | 307 | $I->assertEquals($this->_curl->responseCode, 200); 308 | $I->assertEquals($this->_curl->responseHeaders['location'], 'http://somelocation/'); 309 | $I->assertEquals($this->_curl->responseHeaders['param'], 'value'); 310 | } 311 | 312 | 313 | /** 314 | * Default head method test 315 | * @param FunctionalTester $I 316 | * @throws Exception 317 | */ 318 | public function defaultHeadMethodTest(\FunctionalTester $I) 319 | { 320 | //Init 321 | $this->_curl->reset(); 322 | 323 | $I->expectARequestToRemoteServiceWithAResponse( 324 | 325 | Phiremock::on( 326 | A::headRequest()->andUrl(Is::equalTo('/test/head')) 327 | )->then( 328 | Respond::withStatusCode(200) 329 | ) 330 | ); 331 | 332 | $this->_curl->head($this->_endPoint . '/test/head'); 333 | $I->assertEquals($this->_curl->responseCode, 200); 334 | } 335 | 336 | 337 | /** 338 | * Default delete method test 339 | * @param FunctionalTester $I 340 | * @throws Exception 341 | */ 342 | public function defaultDeleteMethodTest(\FunctionalTester $I) 343 | { 344 | //Init 345 | $this->_curl->reset(); 346 | 347 | $I->expectARequestToRemoteServiceWithAResponse( 348 | 349 | Phiremock::on( 350 | A::deleteRequest()->andUrl(Is::equalTo('/test/head')) 351 | )->then( 352 | Respond::withStatusCode(200) 353 | ) 354 | ); 355 | 356 | $this->_curl->delete($this->_endPoint . '/test/head'); 357 | $I->assertEquals($this->_curl->responseCode, 200); 358 | } 359 | 360 | 361 | /** 362 | * Default patch method test 363 | * @param FunctionalTester $I 364 | * @throws Exception 365 | */ 366 | public function defaultPatchMethodTest(\FunctionalTester $I) 367 | { 368 | //Init 369 | $this->_curl->reset(); 370 | 371 | $I->expectARequestToRemoteServiceWithAResponse( 372 | 373 | Phiremock::on( 374 | A::patchRequest()->andUrl(Is::equalTo('/test/head')) 375 | ->andHeader('X-HTTP-Method-Override', Is::equalTo('PATCH')) 376 | )->then( 377 | Respond::withStatusCode(200) 378 | ) 379 | ); 380 | 381 | $this->_curl->patch($this->_endPoint . '/test/head'); 382 | $I->assertEquals($this->_curl->responseCode, 200); 383 | } 384 | 385 | 386 | /** 387 | * Default put method test 388 | * @param FunctionalTester $I 389 | * @throws Exception 390 | */ 391 | public function defaultPutMethodTest(\FunctionalTester $I) 392 | { 393 | //Init 394 | $this->_curl->reset(); 395 | 396 | $I->expectARequestToRemoteServiceWithAResponse( 397 | 398 | Phiremock::on( 399 | A::putRequest()->andUrl(Is::equalTo('/test/head')) 400 | )->then( 401 | Respond::withStatusCode(200) 402 | ) 403 | ); 404 | 405 | $this->_curl->put($this->_endPoint . '/test/head'); 406 | $I->assertEquals($this->_curl->responseCode, 200); 407 | } 408 | 409 | 410 | /** 411 | * Set single option test 412 | * @param FunctionalTester $I 413 | * @throws Exception 414 | */ 415 | public function setSingleDefaultOptionTest(\FunctionalTester $I) 416 | { 417 | //Init 418 | $this->_curl->reset(); 419 | $params = [ 420 | 'key' => 'value', 421 | 'secondKey' => 'secondValue' 422 | ]; 423 | 424 | 425 | $I->expectARequestToRemoteServiceWithAResponse( 426 | $expectation = Phiremock::on( 427 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 428 | ->andBody(Is::equalTo(http_build_query($params))) 429 | ->andHeader('Content-Type', Is::equalTo('application/x-www-form-urlencoded')) 430 | ->andHeader('user-agent', Is::equalTo('my-agent')) 431 | )->then( 432 | Respond::withStatusCode(200) 433 | ) 434 | ); 435 | 436 | $this->_curl->setOption(CURLOPT_USERAGENT, 'my-agent') 437 | ->setPostParams($params) 438 | ->post($this->_endPoint . '/test/params/post'); 439 | 440 | $I->assertEquals($this->_curl->responseCode, 200); 441 | } 442 | 443 | 444 | /** 445 | * Set multiple option test 446 | * @param FunctionalTester $I 447 | * @throws Exception 448 | */ 449 | public function setMultipleOptionsTest(\FunctionalTester $I) 450 | { 451 | //Init 452 | $this->_curl->reset(); 453 | $params = [ 454 | 'key' => 'value', 455 | 'secondKey' => 'secondValue' 456 | ]; 457 | 458 | 459 | $I->expectARequestToRemoteServiceWithAResponse( 460 | $expectation = Phiremock::on( 461 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 462 | ->andBody(Is::equalTo(http_build_query($params))) 463 | ->andHeader('Content-Type', Is::equalTo('application/x-www-form-urlencoded')) 464 | )->then( 465 | Respond::withStatusCode(200) 466 | ) 467 | ); 468 | 469 | $this->_curl->setOptions([ 470 | CURLOPT_USERAGENT => 'my-agent', 471 | CURLOPT_POSTFIELDS => http_build_query($params) 472 | ]) 473 | ->post($this->_endPoint . '/test/params/post'); 474 | 475 | $I->assertEquals($this->_curl->responseCode, 200); 476 | } 477 | 478 | 479 | /** 480 | * Set and unset option test 481 | * @param FunctionalTester $I 482 | * @throws Exception 483 | */ 484 | public function setUnsetSingleOptionTest(\FunctionalTester $I) 485 | { 486 | //Init 487 | $this->_curl->reset(); 488 | $params = [ 489 | 'key' => 'value', 490 | 'secondKey' => 'secondValue' 491 | ]; 492 | 493 | $I->expectARequestToRemoteServiceWithAResponse( 494 | $expectation = Phiremock::on( 495 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 496 | ->andBody(Is::equalTo('')) 497 | )->then( 498 | Respond::withStatusCode(200) 499 | ) 500 | ); 501 | 502 | $this->_curl->setOption(CURLOPT_POSTFIELDS, http_build_query($params)) 503 | ->unsetOption(CURLOPT_POSTFIELDS) 504 | ->post($this->_endPoint . '/test/params/post'); 505 | 506 | $I->assertEquals($this->_curl->responseCode, 200); 507 | } 508 | 509 | 510 | /** 511 | * Set and unset all options test 512 | * @param FunctionalTester $I 513 | * @throws Exception 514 | */ 515 | public function setAllAndUnsertOptionsTest(\FunctionalTester $I) 516 | { 517 | //Init 518 | $this->_curl->reset(); 519 | $params = [ 520 | 'key' => 'value', 521 | 'secondKey' => 'secondValue' 522 | ]; 523 | 524 | $I->expectARequestToRemoteServiceWithAResponse( 525 | $expectation = Phiremock::on( 526 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 527 | ->andBody(Is::equalTo('')) 528 | )->then( 529 | Respond::withStatusCode(200) 530 | ) 531 | ); 532 | 533 | $this->_curl->setOption(CURLOPT_POSTFIELDS, http_build_query($params)) 534 | ->unsetOptions() 535 | ->post($this->_endPoint . '/test/params/post'); 536 | 537 | $I->assertEquals($this->_curl->responseCode, 200); 538 | } 539 | 540 | 541 | /** 542 | * Simple reset after request test 543 | * @param FunctionalTester $I 544 | * @throws Exception 545 | */ 546 | public function resetAfterGet(\FunctionalTester $I) 547 | { 548 | $I->expectARequestToRemoteServiceWithAResponse( 549 | Phiremock::on( 550 | A::getRequest()->andUrl(Is::equalTo('/test/httpStatus/200')) 551 | )->then( 552 | Respond::withStatusCode(200) 553 | ) 554 | ); 555 | 556 | $this->_curl->get($this->_endPoint . '/test/httpStatus/200'); 557 | $I->assertEquals($this->_curl->responseCode, 200); 558 | 559 | $this->_curl->reset(); 560 | $I->assertEquals($this->_curl->curl, null); 561 | } 562 | 563 | 564 | /** 565 | * Simple get info test 566 | * @param FunctionalTester $I 567 | * @throws Exception 568 | */ 569 | public function getInfo(\FunctionalTester $I) 570 | { 571 | $I->expectARequestToRemoteServiceWithAResponse( 572 | Phiremock::on( 573 | A::getRequest()->andUrl(Is::equalTo('/test/httpStatus/200')) 574 | )->then( 575 | Respond::withStatusCode(200) 576 | ) 577 | ); 578 | 579 | $this->_curl->get($this->_endPoint . '/test/httpStatus/200'); 580 | $I->assertEquals($this->_curl->responseCode, 200); 581 | $this->_curl->getInfo(); 582 | } 583 | 584 | 585 | /** 586 | * Simple get info without curl test 587 | * @param \FunctionalTester $I 588 | */ 589 | public function getInfoWithoutCurl(\FunctionalTester $I) 590 | { 591 | $I->assertEquals($this->_curl->getInfo(CURLINFO_HEADER_SIZE ), []); 592 | } 593 | 594 | 595 | /** 596 | * Simple curl timeout test 597 | * @param FunctionalTester $I 598 | * @throws Exception 599 | */ 600 | public function defaultCurlTimeoutError(\FunctionalTester $I) 601 | { 602 | $I->expectARequestToRemoteServiceWithAResponse( 603 | Phiremock::on( 604 | A::getRequest()->andUrl(Is::equalTo('/test/httpStatus/timeout')) 605 | )->then( 606 | Respond::withStatusCode(404) 607 | ->andDelayInMillis(2000) 608 | ) 609 | ); 610 | 611 | $this->_curl->setOption(CURLOPT_TIMEOUT, 1) 612 | ->get($this->_endPoint . '/test/httpStatus/timeout'); 613 | 614 | $I->assertEquals($this->_curl->responseCode, 'timeout'); 615 | } 616 | 617 | 618 | /** 619 | * Simple get without head request 620 | * @param FunctionalTester $I 621 | * @throws Exception 622 | */ 623 | public function simpleGetWithoutHead(\FunctionalTester $I) 624 | { 625 | $I->expectARequestToRemoteServiceWithAResponse( 626 | Phiremock::on( 627 | A::getRequest()->andUrl(Is::equalTo('/test/httpStatus/200')) 628 | )->then( 629 | Respond::withStatusCode(200) 630 | ) 631 | ); 632 | 633 | $this->_curl 634 | ->setOption(CURLOPT_HEADER, false) 635 | ->get($this->_endPoint . '/test/httpStatus/200'); 636 | 637 | $I->assertEquals($this->_curl->responseCode, 200); 638 | } 639 | 640 | 641 | /** 642 | * Simple curl error test CURL_UNSUPPORTED_PROTOCOL 643 | * @param FunctionalTester $I 644 | * @throws Exception 645 | */ 646 | public function defaultCurlError(\FunctionalTester $I) 647 | { 648 | $this->_curl->get( 'messy:/test/httpStatus/timeout'); 649 | 650 | $I->assertEquals($this->_curl->responseCode, null); 651 | $I->assertLessOrEquals($this->_curl->errorCode, 1); 652 | } 653 | 654 | 655 | /** 656 | * Default charset extract test 657 | * @param FunctionalTester $I 658 | * @throws Exception 659 | */ 660 | public function defaultCharsetExtractTest(\FunctionalTester $I) 661 | { 662 | $I->expectARequestToRemoteServiceWithAResponse( 663 | Phiremock::on( 664 | A::getRequest()->andUrl(Is::equalTo('/test/httpStatus/header')) 665 | )->then( 666 | Respond::withStatusCode(200) 667 | ->andHeader('Content-Type', 'application/x-javascript;charset=UTF-8') 668 | ) 669 | ); 670 | 671 | $this->_curl->get($this->_endPoint . '/test/httpStatus/header'); 672 | 673 | $I->assertEquals($this->_curl->responseCharset, 'utf-8'); 674 | } 675 | 676 | 677 | /** 678 | * Try set a header param and check if getHeaders() does return it 679 | * @param FunctionalTester $I 680 | * @throws Exception 681 | */ 682 | public function setHeaderParamAndTestGetHeaders(\FunctionalTester $I) 683 | { 684 | //Init 685 | $this->_curl->reset(); 686 | $params = [ 687 | 'key' => 'value', 688 | 'secondKey' => 'secondValue' 689 | ]; 690 | 691 | $I->expectARequestToRemoteServiceWithAResponse( 692 | $expectation = Phiremock::on( 693 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 694 | ->andBody(Is::equalTo(http_build_query($params))) 695 | ->andHeader('Content-Type', Is::equalTo('application/json')) 696 | )->then( 697 | Respond::withStatusCode(200) 698 | ) 699 | ); 700 | 701 | $this->_curl->setPostParams($params) 702 | ->setHeaders([ 703 | 'Content-Type' => 'application/json' 704 | ]) 705 | ->post($this->_endPoint . '/test/params/post'); 706 | 707 | 708 | //check for count 709 | $I->assertEquals(count($this->_curl->getRequestHeaders()), 1); 710 | 711 | //check for value 712 | $requestHeaders = $this->_curl->getRequestHeaders(); 713 | $I->assertEquals($requestHeaders['Content-Type'], 'application/json'); 714 | } 715 | 716 | 717 | /** 718 | * Try set a header param and check if getHeader() does return it 719 | * @param FunctionalTester $I 720 | * @throws Exception 721 | */ 722 | public function setHeaderParamAndTestGetHeader(\FunctionalTester $I) 723 | { 724 | //Init 725 | $this->_curl->reset(); 726 | $params = [ 727 | 'key' => 'value', 728 | 'secondKey' => 'secondValue' 729 | ]; 730 | 731 | $I->expectARequestToRemoteServiceWithAResponse( 732 | $expectation = Phiremock::on( 733 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 734 | ->andBody(Is::equalTo(http_build_query($params))) 735 | ->andHeader('Content-Type', Is::equalTo('application/json')) 736 | )->then( 737 | Respond::withStatusCode(200) 738 | ) 739 | ); 740 | 741 | $this->_curl->setPostParams($params) 742 | ->setHeaders([ 743 | 'Content-Type' => 'application/json' 744 | ]) 745 | ->post($this->_endPoint . '/test/params/post'); 746 | 747 | 748 | //check for value 749 | $I->assertEquals($this->_curl->getRequestHeader('Content-Type'), 'application/json'); 750 | } 751 | 752 | 753 | /** 754 | * Try set a single header param and check if getRequestHeader() does return it 755 | * @param FunctionalTester $I 756 | * @throws Exception 757 | */ 758 | public function setSingleHeaderParamAndTestGetHeader(\FunctionalTester $I) 759 | { 760 | //Init 761 | $this->_curl->reset(); 762 | $params = [ 763 | 'key' => 'value', 764 | 'secondKey' => 'secondValue' 765 | ]; 766 | 767 | $I->expectARequestToRemoteServiceWithAResponse( 768 | $expectation = Phiremock::on( 769 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 770 | ->andBody(Is::equalTo(http_build_query($params))) 771 | ->andHeader('Content-Type', Is::equalTo('application/json')) 772 | )->then( 773 | Respond::withStatusCode(200) 774 | ) 775 | ); 776 | 777 | $this->_curl->setPostParams($params) 778 | ->setHeader('Content-Type', 'application/json') 779 | ->post($this->_endPoint . '/test/params/post'); 780 | 781 | //check for value 782 | $I->assertEquals($this->_curl->getRequestHeader('Content-Type'), 'application/json'); 783 | } 784 | 785 | 786 | /** 787 | * Try set a single header and multiple headers at once and check if getRequestHeader() does return it 788 | * @param FunctionalTester $I 789 | * @throws Exception 790 | */ 791 | public function setSingleHeaderAndMultipleHeadersAndTestGetHeader(\FunctionalTester $I) 792 | { 793 | //Init 794 | $this->_curl->reset(); 795 | $params = [ 796 | 'key' => 'value', 797 | 'secondKey' => 'secondValue' 798 | ]; 799 | 800 | $I->expectARequestToRemoteServiceWithAResponse( 801 | $expectation = Phiremock::on( 802 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 803 | ->andBody(Is::equalTo(http_build_query($params))) 804 | ->andHeader('Content-Type', Is::equalTo('application/json')) 805 | ->andHeader('custom-type', Is::equalTo('><)#7?aJEvgavJk(*4')) 806 | )->then( 807 | Respond::withStatusCode(200) 808 | ) 809 | ); 810 | 811 | $this->_curl->setPostParams($params) 812 | ->setHeader('Content-Type', 'application/json') 813 | ->setHeaders([ 814 | 'custom-type' => '><)#7?aJEvgavJk(*4' 815 | ]) 816 | ->post($this->_endPoint . '/test/params/post'); 817 | 818 | //check for value 819 | $I->assertEquals($this->_curl->getRequestHeader('Content-Type'), 'application/json'); 820 | $I->assertEquals($this->_curl->getRequestHeader('custom-type'), '><)#7?aJEvgavJk(*4'); 821 | } 822 | 823 | 824 | /** 825 | * Try set a single header, multiple header and unset one header param and check if getRequestHeader() does return it 826 | * @param FunctionalTester $I 827 | * @throws Exception 828 | */ 829 | public function setSingleHeaderAndMultipleHeadersAndUnsetOneTillTestGetHeader(\FunctionalTester $I) 830 | { 831 | //Init 832 | $this->_curl->reset(); 833 | $params = [ 834 | 'key' => 'value', 835 | 'secondKey' => 'secondValue' 836 | ]; 837 | 838 | $I->expectARequestToRemoteServiceWithAResponse( 839 | $expectation = Phiremock::on( 840 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 841 | ->andBody(Is::equalTo(http_build_query($params))) 842 | ->andHeader('Content-Type', Is::equalTo('application/json')) 843 | )->then( 844 | Respond::withStatusCode(200) 845 | ) 846 | ); 847 | 848 | $this->_curl->setPostParams($params) 849 | ->setHeader('Content-Type', 'application/json') 850 | ->setHeaders([ 851 | 'custom-type' => '><)#7?aJEvgavJk(*4' 852 | ]) 853 | ->unsetHeader('custom-type') 854 | ->post($this->_endPoint . '/test/params/post'); 855 | 856 | //check for value 857 | $I->assertEquals($this->_curl->getRequestHeader('Content-Type'), 'application/json'); 858 | $I->assertEquals($this->_curl->getRequestHeader('custom-type'), null); 859 | } 860 | 861 | 862 | /** 863 | * Try set a single header, multiple header and unset one header param and check if getRequestHeader() does return it 864 | * @param FunctionalTester $I 865 | * @throws Exception 866 | */ 867 | public function setMultipleHeadersAndSingleHeaderAndUnsetOneTillTestGetHeader(\FunctionalTester $I) 868 | { 869 | //Init 870 | $this->_curl->reset(); 871 | $params = [ 872 | 'key' => 'value', 873 | 'secondKey' => 'secondValue' 874 | ]; 875 | 876 | $I->expectARequestToRemoteServiceWithAResponse( 877 | $expectation = Phiremock::on( 878 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 879 | ->andBody(Is::equalTo(http_build_query($params))) 880 | ->andHeader('Content-Type', Is::equalTo('application/json')) 881 | )->then( 882 | Respond::withStatusCode(200) 883 | ) 884 | ); 885 | 886 | $this->_curl->setPostParams($params) 887 | ->setHeaders([ 888 | 'custom-type' => '><)#7?aJEvgavJk(*4' 889 | ]) 890 | ->setHeader('Content-Type', 'application/json') 891 | ->unsetHeader('custom-type') 892 | ->post($this->_endPoint . '/test/params/post'); 893 | 894 | //check for value 895 | $I->assertEquals($this->_curl->getRequestHeader('Content-Type'), 'application/json'); 896 | $I->assertEquals($this->_curl->getRequestHeader('custom-type'), null); 897 | } 898 | 899 | 900 | /** 901 | * Try to post raw json string 902 | * @param FunctionalTester $I 903 | * @throws Exception 904 | */ 905 | public function setRawPostDataTest (\FunctionalTester $I) 906 | { 907 | //Init 908 | $this->_curl->reset(); 909 | $params = [ 910 | 'key' => 'value', 911 | 'secondKey' => 'secondValue' 912 | ]; 913 | 914 | $I->expectARequestToRemoteServiceWithAResponse( 915 | $expectation = Phiremock::on( 916 | A::postRequest()->andUrl(Is::equalTo('/test/params/post')) 917 | ->andBody(Is::equalTo(json_encode($params))) 918 | ->andHeader('Content-Type', Is::equalTo('application/json')) 919 | )->then( 920 | Respond::withStatusCode(200) 921 | ) 922 | ); 923 | 924 | $this->_curl->setRawPostData(json_encode($params)) 925 | ->setHeader('Content-Type', 'application/json') 926 | ->post($this->_endPoint . '/test/params/post'); 927 | 928 | //check for value 929 | $I->assertEquals($this->_curl->getRequestHeader('Content-Type'), 'application/json'); 930 | } 931 | 932 | /** 933 | * Simple HTTP ok 934 | * @param FunctionalTester $I 935 | * @throws Exception 936 | */ 937 | public function simpleOptionsOkTest(\FunctionalTester $I) 938 | { 939 | $I->expectARequestToRemoteServiceWithAResponse( 940 | Phiremock::on( 941 | A::optionsRequest()->andUrl(Is::equalTo('/test/httpStatus/204')) 942 | )->then( 943 | Respond::withStatusCode(204) 944 | ) 945 | ); 946 | 947 | $this->_curl->options($this->_endPoint . '/test/httpStatus/204'); 948 | $I->assertEquals($this->_curl->responseCode, 204); 949 | } 950 | } 951 | -------------------------------------------------------------------------------- /tests/unit.suite.yml: -------------------------------------------------------------------------------- 1 | # Codeception Test Suite Configuration 2 | # 3 | # Suite for unit (internal) tests. 4 | 5 | class_name: UnitTester 6 | modules: 7 | enabled: 8 | - Asserts 9 | - \Helper\Unit -------------------------------------------------------------------------------- /tests/unit/CurlTest.php: -------------------------------------------------------------------------------- 1 | assertTrue($curl instanceof linslin\yii2\curl\Curl); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /tests/unit/_bootstrap.php: -------------------------------------------------------------------------------- 1 |