CurlTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\HTTP\Test\Unit\Adapter;
  7. use \Magento\Framework\HTTP\Adapter\Curl;
  8. class CurlTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var Curl
  12. */
  13. protected $model;
  14. /**
  15. * @var \Closure
  16. */
  17. public static $curlExectClosure;
  18. protected function setUp()
  19. {
  20. require_once __DIR__ . '/_files/curl_exec_mock.php';
  21. $this->model = new \Magento\Framework\HTTP\Adapter\Curl();
  22. }
  23. /**
  24. * @param string $response
  25. * @dataProvider readDataProvider
  26. */
  27. public function testRead($response)
  28. {
  29. self::$curlExectClosure = function () use ($response) {
  30. return $response;
  31. };
  32. $this->assertEquals(file_get_contents(__DIR__ . '/_files/curl_response_expected.txt'), $this->model->read());
  33. }
  34. /**
  35. * @return array
  36. */
  37. public function readDataProvider()
  38. {
  39. return [
  40. [file_get_contents(__DIR__ . '/_files/curl_response1.txt')],
  41. [file_get_contents(__DIR__ . '/_files/curl_response2.txt')],
  42. ];
  43. }
  44. }