From 01e89e36526724df3efa98350a64654e4e9f14ad Mon Sep 17 00:00:00 2001 From: droletmarc Date: Fri, 14 Jul 2017 08:24:01 -0400 Subject: [PATCH 1/7] - I've added code to remove the temporary session file that get create on each rets request. This file is not used anymore once we get the gets server response and it didn't get removed. - /tmp folder was hardcoded, I've added a way to configure it into the configuration of the PHRets. By default it will be null. --- src/Configuration.php | 19 +++++++++++++++++++ src/Session.php | 21 +++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/Configuration.php b/src/Configuration.php index d2e9bb9..0657ba9 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -20,6 +20,7 @@ class Configuration protected $http_authentication = 'digest'; /** @var \PHRETS\Strategies\Strategy */ protected $strategy; + protected $sessionTempDir = null; protected $options = []; public function __construct() @@ -135,6 +136,24 @@ public function setUsername($username) return $this; } + /** + * @param string $username + * @return $this + */ + public function setSessionTempDir($sessionTempDir) + { + $this->sessionTempdDir = $sessionTempDir; + return $this; + } + + /** + * @return mixed + */ + public function getSessionTempDir() + { + return $this->sessionTempDir; + } + /** * @param $name * @param $value diff --git a/src/Session.php b/src/Session.php index 63ba0a5..e85aea2 100644 --- a/src/Session.php +++ b/src/Session.php @@ -339,6 +339,8 @@ protected function request($capability, $options = []) $response = new \PHRETS\Http\Response($response); + $this->removeSessionCookieFile($options); + $this->last_response = $response; if ($response->getHeader('Set-Cookie')) { @@ -349,7 +351,7 @@ protected function request($capability, $options = []) } } } - + if (preg_match('/text\/xml/', $response->getHeader('Content-Type')) and $capability != 'GetObject') { $parser = $this->grab(Strategy::PARSER_XML); $xml = $parser->parse($response); @@ -481,7 +483,7 @@ public function getDefaultOptions() 'Accept-Encoding' => 'gzip', 'Accept' => '*/*', ], - 'curl' => [ CURLOPT_COOKIEFILE => tempnam('/tmp', 'phrets') ] + 'curl' => [ CURLOPT_COOKIEFILE => tempnam($this->configuration->getSessionTempDir(), 'phrets') ] ]; // disable following 'Location' header (redirects) automatically @@ -492,6 +494,21 @@ public function getDefaultOptions() return $defaults; } + /** + * If the session cookie file have beend created, we will remove it. + * + * @param array $options Assoc array that came from the method getDefaultOptions. + * + * @return void + */ + private function removeSessionCookieFile(array $options) + { + $tmpFile = $options['curl'][CURLOPT_COOKIEFILE]; + if (file_exists($tmpFile)) { + unlink($tmpFile); + } + } + public function setParser($parser_name, $parser_object) { /** @var Container $container */ From aaf595c993d05702e8a91283a06678b314fe1286 Mon Sep 17 00:00:00 2001 From: droletmarc Date: Thu, 3 Aug 2017 10:37:06 -0400 Subject: [PATCH 2/7] Some rets service, like the one from bridge-rets.mlspin.com do not work if you pass a value (basic or digest) into the http_authentication. I've modify the code to be able to pass http_authentication = null when we set the config. --- src/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Configuration.php b/src/Configuration.php index 0657ba9..f222489 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -259,7 +259,7 @@ public function userAgentDigestHash(Session $session) */ public function setHttpAuthenticationMethod($auth_method) { - if (!in_array($auth_method, [self::AUTH_BASIC, self::AUTH_DIGEST])) { + if ($auth_method && !in_array($auth_method, [self::AUTH_BASIC, self::AUTH_DIGEST])) { throw new \InvalidArgumentException("Given authentication method is invalid. Must be 'basic' or 'digest'"); } $this->http_authentication = $auth_method; From 788d1ec8147ac88a81fbbe437e583357b27bf208 Mon Sep 17 00:00:00 2001 From: droletmarc Date: Thu, 3 Aug 2017 10:43:28 -0400 Subject: [PATCH 3/7] revert --- src/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Configuration.php b/src/Configuration.php index f222489..0657ba9 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -259,7 +259,7 @@ public function userAgentDigestHash(Session $session) */ public function setHttpAuthenticationMethod($auth_method) { - if ($auth_method && !in_array($auth_method, [self::AUTH_BASIC, self::AUTH_DIGEST])) { + if (!in_array($auth_method, [self::AUTH_BASIC, self::AUTH_DIGEST])) { throw new \InvalidArgumentException("Given authentication method is invalid. Must be 'basic' or 'digest'"); } $this->http_authentication = $auth_method; From 543a7980437cfeef79c813f8d98b2eb70ae9a084 Mon Sep 17 00:00:00 2001 From: droletmarc Date: Thu, 3 Aug 2017 10:44:06 -0400 Subject: [PATCH 4/7] Some rets service, like the one from bridge-rets.mlspin.com do not work if you pass a value (basic or digest) into the http_authentication. I've modify the code to be able to pass http_authentication = null when we set the config. --- src/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Configuration.php b/src/Configuration.php index 0657ba9..f222489 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -259,7 +259,7 @@ public function userAgentDigestHash(Session $session) */ public function setHttpAuthenticationMethod($auth_method) { - if (!in_array($auth_method, [self::AUTH_BASIC, self::AUTH_DIGEST])) { + if ($auth_method && !in_array($auth_method, [self::AUTH_BASIC, self::AUTH_DIGEST])) { throw new \InvalidArgumentException("Given authentication method is invalid. Must be 'basic' or 'digest'"); } $this->http_authentication = $auth_method; From 6811763a2cd940f09a43c7cd0deef8a45388c1c3 Mon Sep 17 00:00:00 2001 From: droletmarc Date: Wed, 15 Aug 2018 15:46:12 -0400 Subject: [PATCH 5/7] XmlParseException on login #73 SimpleXmlElement return an error when the content of the string is not valid UTF-8 chars. I've make sure the content is UTF-8. other chars get discarded --- src/Parsers/XML.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Parsers/XML.php b/src/Parsers/XML.php index 7309ca1..257d8d1 100644 --- a/src/Parsers/XML.php +++ b/src/Parsers/XML.php @@ -11,6 +11,20 @@ public function parse($string) $string = $string->getBody()->__toString(); } - return new \SimpleXMLElement((string) $string); + $string = (string) $string; + + /** + * Some rets provider(s) return invalid XML data. + * Here we make sure the returned data are UTF-8 valid chars. + * I've seen so far: + * - windows carriage return (^M at the end of each lines) + * - trade mark sign not converted to ™ and I guess we can have other sigh like this. + * + * NOTE: + * //IGNORE will discard the invalid UTF-8 chars. + */ + $string = iconv(mb_detect_encoding($string), 'UTF-8//IGNORE', $string); + + return new \SimpleXMLElement($string); } } From 5f8faa55840e1ccfe4d3a0c2a85e13d41774f883 Mon Sep 17 00:00:00 2001 From: droletmarc Date: Wed, 15 Aug 2018 15:52:02 -0400 Subject: [PATCH 6/7] I've added php required exception iconv and mbstring --- composer.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/composer.json b/composer.json index 3a4f87a..e5303a8 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,8 @@ ], "require": { "php": ">=5.5.0", + "ext-iconv": "*", + "ext-mbstring": "*", "guzzlehttp/guzzle": ">=6.0", "illuminate/container": ">=4.2.0", "illuminate/support": ">=4.2.0", From f3275a189d9db0dff0d3efc3983cd9eac802b954 Mon Sep 17 00:00:00 2001 From: droletmarc Date: Thu, 30 Aug 2018 09:23:22 -0400 Subject: [PATCH 7/7] merge with troydavisson-master master branch to bring new fix --- .travis.yml | 1 + README.md | 3 +- docs/changelog.md | 23 +++++ docs/start.md | 2 +- phpunit.xml.dist | 5 + src/Configuration.php | 2 +- src/Http/Response.php | 9 +- src/Interpreters/GetObject.php | 4 +- src/Models/{Object.php => BaseObject.php} | 2 +- src/Models/Metadata/Base.php | 11 +- .../Metadata/{Object.php => BaseObject.php} | 2 +- src/Models/Metadata/Resource.php | 2 +- .../{Object.php => BaseObject.php} | 4 +- src/Parsers/GetObject/Single.php | 4 +- src/Parsers/Login/OneEight.php | 29 ++++-- src/Parsers/Search/OneX.php | 29 ++++-- src/Session.php | 94 +++++++++++++++--- src/Strategies/StandardStrategy.php | 2 +- tests/Http/ResponseTest.php | 26 +++++ tests/Integration/BaseIntegration.php | 1 + ...t => d5d441322368e5c2ad059621979b0d88.txt} | 0 ...t => 03cd0f6cb206f18aed8f4979939a9482.txt} | 0 ...t => d848b86daf1f828cdf637404afc72626.txt} | 0 ...t => 9d3ab35ecd3b097760867c2d7259ed83.txt} | 0 ...t => e057db12dc3a7f37caa2203ecc2fe13e.txt} | 0 ...t => 0c110d39a7815a91b58a68006aa42dbf.txt} | 0 ...t => 3f61a38b92bfdb51eaf133bf516b2483.txt} | 0 ...t => 4f4529540496ce9bc194500a6d109a2c.txt} | 0 ...t => 785c884c29c4c4d17deb0fcd89cd5282.txt} | 0 ...t => 940a2bcb4240708a30ed3e4abd2a3056.txt} | 0 ...t => 9d194ccfcc9edb5a93dea267d1f9c91d.txt} | 0 ...t => 9ed93625ec4cad577e42158701ae7b44.txt} | 0 ...t => b3a4345b713492d24315d1f92665d7a6.txt} | 0 ...t => bbe857812f04d9e40c3508c212ab0ebe.txt} | 0 ...t => 204749e19efea78e43edf1f3333ee44b.txt} | Bin ...t => 27e68249f6feeb17925a7af12c75e3e9.txt} | 0 ...t => bc184498e2ca6712c7c2e8f5a4cec90e.txt} | 0 ...t => aaae3d614d1660701f3d7508efb11004.txt} | 0 ...t => ac1f434b220d1920fa87a27d582bc877.txt} | 0 ...t => e5df43b61e717bc8e3d4759aad894e2f.txt} | 0 ...t => 18f6b7bfb97630b9cdbfd8af1b817310.txt} | 0 ...t => 1aa3b4454404b11492369cc3f2b95e8f.txt} | 0 ...t => 5836410b43446216e8b33c787d798441.txt} | 0 ...t => 71fb8c90d106cf1f88c5687044918787.txt} | 0 ...t => 7580aa7ffcd519406def9899f7efbb41.txt} | 0 ...t => 772dbb6548885978fd7b656175e0b817.txt} | 0 ...t => 77bebac441fa391975e56cb720f2d7e7.txt} | 0 ...t => 90471d12722b9f16e7568920b861cf1f.txt} | 0 ...t => c0296526b8e1e8954a8001dbb85b01ea.txt} | 0 ...t => e9f250f06854ab0e94b017681e91c7bd.txt} | 0 ...t => f065035031b4ce43d3e5374517306e20.txt} | 0 ...t => f07c8bc25411e40b67847cef66883ab5.txt} | 0 ...t => f32d4206aad8af73adadb03e5b066e0e.txt} | 0 ...t => 1af5d18d3171486377f6fe6c09cda258.txt} | 0 ...t => 57b9c3a515cb43d1141653c3f1395981.txt} | 0 ...t => 7dcdeb3bc5ff839b94836fb3ec2ff947.txt} | 0 .../GetMetadataIntegrationTest.php | 2 +- .../Integration/GetObjectIntegrationTest.php | 4 +- tests/Models/ObjectTest.php | 12 +-- tests/Parsers/GetObject/MultipleTest.php | 4 +- 60 files changed, 217 insertions(+), 60 deletions(-) rename src/Models/{Object.php => BaseObject.php} (99%) rename src/Models/Metadata/{Object.php => BaseObject.php} (96%) rename src/Parsers/GetMetadata/{Object.php => BaseObject.php} (89%) create mode 100644 tests/Http/ResponseTest.php rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/action_rets2_1_Action/{c137023b38529b645fb39f8ad8279cd2.txt => d5d441322368e5c2ad059621979b0d88.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/action_rets2_1_Login/{5f7f2002a41ef7e295cfafd7761604d6.txt => 03cd0f6cb206f18aed8f4979939a9482.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/limited_rets2_1_Login/{68c849d40907d376c5153ca76ab1d634.txt => d848b86daf1f828cdf637404afc72626.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/lookup_rets2_1_GetMetadata/{bd570d3244346c277957e9dc9ce96fc8.txt => 9d3ab35ecd3b097760867c2d7259ed83.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/lookup_rets2_1_Login/{57224dadb1ad87b8f1bd78a01e7df105.txt => e057db12dc3a7f37caa2203ecc2fe13e.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/{a119a87749b5f4b78b7dfe5b75fc5633.txt => 0c110d39a7815a91b58a68006aa42dbf.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/{705cd7b6d6d27671d294262498e8ea9e.txt => 3f61a38b92bfdb51eaf133bf516b2483.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/{9161d31000e27336c1b3b62820d9d365.txt => 4f4529540496ce9bc194500a6d109a2c.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/{379d895fdf3587f9e3879ca8c8cb40a1.txt => 785c884c29c4c4d17deb0fcd89cd5282.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/{a33b15858edd47a185f6f221df597a92.txt => 940a2bcb4240708a30ed3e4abd2a3056.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/{dc95b8e6f7ce96e7a84dec6c571895ab.txt => 9d194ccfcc9edb5a93dea267d1f9c91d.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/{ae3834bdb8c3dd003ba4c4a8c48baf3e.txt => 9ed93625ec4cad577e42158701ae7b44.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/{7c63f0c3acee0a8ca156b41299f9ed70.txt => b3a4345b713492d24315d1f92665d7a6.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/{001eb002b7463e2bc06a044733411ca2.txt => bbe857812f04d9e40c3508c212ab0ebe.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/{ba551e44d6528c00ab5316c22d9b2333.txt => 204749e19efea78e43edf1f3333ee44b.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/{f6845defd645868b92e6334220bf1033.txt => 27e68249f6feeb17925a7af12c75e3e9.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/{932d1b74540ce51a9c52eb5991f8d32e.txt => bc184498e2ca6712c7c2e8f5a4cec90e.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/{5826ab498becc30e0b4bdfc76fd446eb.txt => aaae3d614d1660701f3d7508efb11004.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/{e604e7ffd22cf87f27243e1447be9a6e.txt => ac1f434b220d1920fa87a27d582bc877.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/{b0c026e533aab116e08ea714815d0e22.txt => e5df43b61e717bc8e3d4759aad894e2f.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Logout/{38a4125fc6d66ec797b2d99573ab4ba9.txt => 18f6b7bfb97630b9cdbfd8af1b817310.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{afa92fb5f24842390c8f6cd6a99bb001.txt => 1aa3b4454404b11492369cc3f2b95e8f.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{0f0673d2ef2a477d342a7a0437289f2a.txt => 5836410b43446216e8b33c787d798441.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{393e7f69f016ec9997893ddf90d8fbbf.txt => 71fb8c90d106cf1f88c5687044918787.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{57e666dcbb001b95fe6ce5cc6b50f9c6.txt => 7580aa7ffcd519406def9899f7efbb41.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{ab7c6098ce63dacbf763ae6a39eba7f8.txt => 772dbb6548885978fd7b656175e0b817.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{1e854d81ef520df4a3789556943739a7.txt => 77bebac441fa391975e56cb720f2d7e7.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{5cde31d395414b0591f8ddf919ac15c2.txt => 90471d12722b9f16e7568920b861cf1f.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{da959b0ae1504119844e6c4cb9677b80.txt => c0296526b8e1e8954a8001dbb85b01ea.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{b012748c0e118d0b39a6636107f0f1d5.txt => e9f250f06854ab0e94b017681e91c7bd.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{46f251b82fcb364d35c361bd96fc61f6.txt => f065035031b4ce43d3e5374517306e20.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{60f1a0663d376a146a8c9bfc1619c612.txt => f07c8bc25411e40b67847cef66883ab5.txt} (100%) rename tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/{b8fa19ea891acc0542e40873643f8656.txt => f32d4206aad8af73adadb03e5b066e0e.txt} (100%) rename tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_GetMetadata/{3db9d8ee35ba1b9435e9d6ca037c1616.txt => 1af5d18d3171486377f6fe6c09cda258.txt} (100%) rename tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_Login/{ec520b6cefeb5cbeef8f44437ad3949d.txt => 57b9c3a515cb43d1141653c3f1395981.txt} (100%) rename tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_Search/{e27485932867c790503de2bfeb86ec2d.txt => 7dcdeb3bc5ff839b94836fb3ec2ff947.txt} (100%) diff --git a/.travis.yml b/.travis.yml index af5d5ef..5e81a43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ php: - 5.6 - 7.0 - 7.1 + - 7.2 - hhvm before_script: composer install env: diff --git a/README.md b/README.md index 076d14a..9e34bd8 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ PHRETS provides PHP developers a way to integrate RETS functionality directly wi * HTTP Header management * Authentication * Session/Cookie management +* PHP 5.6, 7.0, 7.1 and 7.2 supported ### Installation @@ -255,7 +256,7 @@ $objects->last(); $objects = $objects->slice(0, 10); ``` -Each object within that collection is a `\PHRETS\Models\Object` object with it's own set of helper methods: +Each object within that collection is a `\PHRETS\Models\BaseObject` object with it's own set of helper methods: ```php $objects = $rets->GetObject( see above documentation ); diff --git a/docs/changelog.md b/docs/changelog.md index e862143..3f27834 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,29 @@ _Release TBD_ +## 2.6.1 + +_Released March 22, 2018_ + +* Fix header version to correctly reflect the new version + +## 2.6 + +_Released March 22, 2018_ + +* Support for PHP 7.2 +* `PHRETS\Models\Object` renamed to `PHRETS\Models\BaseObject` +* `PHRETS\Models\Metadata\Object` renamed to `PHRETS\Models\Metadata\BaseObject` +* `PHRETS\Parsers\GetMetadata\Object` renamed to `PHRETS\Parsers\GetMetadata\BaseObject` + +## 2.5 + +_Released October 23, 2017_ + +- Fix RETS 1.8 login response parsing for optional info-token-type +- Support automatic re-login if session issue occurs mid-process +- New option `disable_auto_retry` (bool) added to optionally disable automatic re-login behavior + ## 2.4 _Released June 28, 2017_ diff --git a/docs/start.md b/docs/start.md index 0a0a2ee..5309ebf 100644 --- a/docs/start.md +++ b/docs/start.md @@ -8,7 +8,7 @@ It's best to install [PHRETS](https://packagist.org/packages/troydavisson/PHRETS # Basic Requirements -* PHP 5.4+ +* PHP 5.6+ * Installed via [Composer](http://getcomposer.org) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1e02431..6b4d0b4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -26,4 +26,9 @@ + + + + + diff --git a/src/Configuration.php b/src/Configuration.php index f222489..22c246a 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -13,7 +13,7 @@ class Configuration protected $username; protected $password; protected $login_url; - protected $user_agent = 'PHRETS/2.0'; + protected $user_agent = 'PHRETS/2.6.1'; protected $user_agent_password; /** @var RETSVersion */ protected $rets_version; diff --git a/src/Http/Response.php b/src/Http/Response.php index acb88ca..f51abfc 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -21,7 +21,12 @@ public function __construct(ResponseInterface $response) public function xml() { - return new \SimpleXMLElement((string) $this->response->getBody()); + $body = (string) $this->response->getBody(); + + // Remove any carriage return / newline in XML response. + $body = trim($body); + + return new \SimpleXMLElement($body); } public function __call($method, $args = []) @@ -32,7 +37,7 @@ public function __call($method, $args = []) public function getHeader($name) { $headers = $this->response->getHeader($name); - + if ($headers) { return implode('; ', $headers); } else { diff --git a/src/Interpreters/GetObject.php b/src/Interpreters/GetObject.php index 6fc11b2..3e06446 100644 --- a/src/Interpreters/GetObject.php +++ b/src/Interpreters/GetObject.php @@ -30,9 +30,9 @@ public static function ids($content_ids, $object_ids) protected static function split($value, $dash_ranges = true) { if (!is_array($value)) { - if (preg_match('/\:/', $value)) { + if (stripos($value, ':') !== false) { $value = array_map('trim', explode(':', $value)); - } elseif (preg_match('/\,/', $value)) { + } elseif (stripos($value, ',') !== false) { $value = array_map('trim', explode(',', $value)); } elseif ($dash_ranges and preg_match('/(\d+)\-(\d+)/', $value, $matches)) { $value = range($matches[1], $matches[2]); diff --git a/src/Models/Object.php b/src/Models/BaseObject.php similarity index 99% rename from src/Models/Object.php rename to src/Models/BaseObject.php index cb6dd7d..9f1ca74 100644 --- a/src/Models/Object.php +++ b/src/Models/BaseObject.php @@ -1,6 +1,6 @@ getXmlElements(), $this->getXmlAttributes()) as $attr) { - if (strtolower('set' . $attr) == strtolower($name)) { + if (strtolower('set' . $attr) == $name) { $this->values[$attr] = $args[0]; break; } } return $this; - } elseif (preg_match('/^get/', strtolower($name))) { + } elseif ($action === 'get') { foreach (array_merge($this->getXmlElements(), $this->getXmlAttributes()) as $attr) { - if (strtolower('get' . $attr) == strtolower($name)) { + if (strtolower('get' . $attr) == $name) { return \array_get($this->values, $attr); } } diff --git a/src/Models/Metadata/Object.php b/src/Models/Metadata/BaseObject.php similarity index 96% rename from src/Models/Metadata/Object.php rename to src/Models/Metadata/BaseObject.php index 22cd9d1..cec46e3 100644 --- a/src/Models/Metadata/Object.php +++ b/src/Models/Metadata/BaseObject.php @@ -15,7 +15,7 @@ * @method string getDate * @method string getResource */ -class Object extends Base +class BaseObject extends Base { protected $elements = [ 'MetadataEntryID', diff --git a/src/Models/Metadata/Resource.php b/src/Models/Metadata/Resource.php index 8c54ee0..01694bd 100644 --- a/src/Models/Metadata/Resource.php +++ b/src/Models/Metadata/Resource.php @@ -72,7 +72,7 @@ public function getClasses() } /** - * @return \Illuminate\Support\Collection|\PHRETS\Models\Metadata\Object[] + * @return \Illuminate\Support\Collection|\PHRETS\Models\Metadata\BaseObject[] */ public function getObject() { diff --git a/src/Parsers/GetMetadata/Object.php b/src/Parsers/GetMetadata/BaseObject.php similarity index 89% rename from src/Parsers/GetMetadata/Object.php rename to src/Parsers/GetMetadata/BaseObject.php index 3fa713e..ab6026c 100644 --- a/src/Parsers/GetMetadata/Object.php +++ b/src/Parsers/GetMetadata/BaseObject.php @@ -4,7 +4,7 @@ use Illuminate\Support\Collection; use PHRETS\Session; -class Object extends Base +class BaseObject extends Base { public function parse(Session $rets, Response $response) { @@ -17,7 +17,7 @@ public function parse(Session $rets, Response $response) if ($xml->METADATA) { if ($xml->METADATA->{'METADATA-OBJECT'}) { foreach ($xml->METADATA->{'METADATA-OBJECT'}->Object as $key => $value) { - $metadata = new \PHRETS\Models\Metadata\Object; + $metadata = new \PHRETS\Models\Metadata\BaseObject; $metadata->setSession($rets); $obj = $this->loadFromXml($metadata, $value, $xml->METADATA->{'METADATA-OBJECT'}); $collection->put($obj->getObjectType(), $obj); diff --git a/src/Parsers/GetObject/Single.php b/src/Parsers/GetObject/Single.php index 56cd667..a4b5075 100644 --- a/src/Parsers/GetObject/Single.php +++ b/src/Parsers/GetObject/Single.php @@ -1,7 +1,7 @@ getHeaders(); - $obj = new Object; + $obj = new BaseObject; $obj->setContent(($response->getBody()) ? $response->getBody()->__toString() : null); $obj->setContentDescription(\array_get($headers, 'Content-Description', [null])[0]); $obj->setContentSubDescription(\array_get($headers, 'Content-Sub-Description', [null])[0]); diff --git a/src/Parsers/Login/OneEight.php b/src/Parsers/Login/OneEight.php index f5e247f..b9594b5 100644 --- a/src/Parsers/Login/OneEight.php +++ b/src/Parsers/Login/OneEight.php @@ -1,5 +1,7 @@ getDelimiter($rets, $xml, $parameters); + $delimLength = strlen($delim); // break out and track the column names in the response $column_names = "{$xml->COLUMNS[0]}"; - // take out the first delimiter - $column_names = preg_replace("/^{$delim}/", "", $column_names); + // Take out the first delimiter + if (substr($column_names, 0, $delimLength) == $delim) { + $column_names = substr($column_names, $delimLength); + } - // take out the last delimiter - $column_names = preg_replace("/{$delim}\$/", "", $column_names); + // Take out the last delimiter + if (substr($column_names, -$delimLength) == $delim) { + $column_names = substr($column_names, 0, -$delimLength); + } // parse and return the rest return explode($delim, $column_names); @@ -109,13 +114,21 @@ protected function parseRecords(Session $rets, &$xml, $parameters, Results $rs) protected function parseRecordFromLine(Session $rets, &$xml, $parameters, &$line, Results $rs) { $delim = $this->getDelimiter($rets, $xml, $parameters); + $delimLength = strlen($delim); $r = new Record; - $field_data = (string)$line; + $field_data = (string) $line; + + // Take out the first delimiter + if (substr($field_data, 0, $delimLength) == $delim) { + $field_data = substr($field_data, $delimLength); + } + + // Take out the last delimiter + if (substr($field_data, -$delimLength) == $delim) { + $field_data = substr($field_data, 0, -$delimLength); + } - // split up DATA row on delimiter found earlier - $field_data = preg_replace("/^{$delim}/", "", $field_data); - $field_data = preg_replace("/{$delim}\$/", "", $field_data); $field_data = explode($delim, $field_data); foreach ($rs->getHeaders() as $key => $name) { diff --git a/src/Session.php b/src/Session.php index e85aea2..bc18c50 100644 --- a/src/Session.php +++ b/src/Session.php @@ -3,6 +3,7 @@ use GuzzleHttp\Client; use GuzzleHttp\Cookie\CookieJar; use GuzzleHttp\Cookie\CookieJarInterface; +use GuzzleHttp\Exception\ClientException; use Illuminate\Container\Container; use Illuminate\Support\Collection; use PHRETS\Exceptions\CapabilityUnavailable; @@ -12,6 +13,7 @@ use PHRETS\Http\Client as PHRETSClient; use PHRETS\Interpreters\GetObject; use PHRETS\Interpreters\Search; +use PHRETS\Models\BaseObject; use PHRETS\Models\Bulletin; use PHRETS\Strategies\Strategy; use Psr\Http\Message\ResponseInterface; @@ -96,7 +98,7 @@ public function Login() * @param $type * @param $content_id * @param int $location - * @return \PHRETS\Models\Object + * @return \PHRETS\Models\BaseObject */ public function GetPreferredObject($resource, $type, $content_id, $location = 0) { @@ -110,7 +112,7 @@ public function GetPreferredObject($resource, $type, $content_id, $location = 0) * @param $content_ids * @param string $object_ids * @param int $location - * @return Collection + * @return Collection|BaseObject[] * @throws Exceptions\CapabilityUnavailable */ public function GetObject($resource, $type, $content_ids, $object_ids = '*', $location = 0) @@ -129,7 +131,7 @@ public function GetObject($resource, $type, $content_ids, $object_ids = '*', $lo ] ); - if (preg_match('/multipart/', $response->getHeader('Content-Type'))) { + if (stripos($response->getHeader('Content-Type'), 'multipart') !== false) { $parser = $this->grab(Strategy::PARSER_OBJECT_MULTIPLE); $collection = $parser->parse($response); } else { @@ -300,11 +302,12 @@ public function Disconnect() /** * @param $capability * @param array $options - * @throws Exceptions\CapabilityUnavailable - * @throws Exceptions\RETSException + * @param bool $is_retry * @return ResponseInterface + * @throws CapabilityUnavailable + * @throws RETSException */ - protected function request($capability, $options = []) + protected function request($capability, $options = [], $is_retry = false) { $url = $this->capabilities->get($capability); @@ -328,13 +331,46 @@ protected function request($capability, $options = []) $this->last_request_url = $url; } - /** @var ResponseInterface $response */ - if ($this->configuration->readOption('use_post_method')) { - $this->debug('Using POST method per use_post_method option'); - $query = (array_key_exists('query', $options)) ? $options['query'] : null; - $response = $this->client->request('POST', $url, array_merge($options, ['form_params' => $query])); - } else { - $response = $this->client->request('GET', $url, $options); + try { + /** @var ResponseInterface $response */ + if ($this->configuration->readOption('use_post_method')) { + $this->debug('Using POST method per use_post_method option'); + $query = (array_key_exists('query', $options)) ? $options['query'] : null; + $response = $this->client->request('POST', $url, array_merge($options, ['form_params' => $query])); + } else { + $response = $this->client->request('GET', $url, $options); + } + } catch (ClientException $e) { + $this->debug("ClientException: " . $e->getCode() . ": " . $e->getMessage()); + + if ($e->getCode() != 401) { + // not an Unauthorized error, so bail + throw $e; + } + + if ($capability == 'Login') { + // unauthorized on a Login request, so bail + throw $e; + } + + if ($is_retry) { + // this attempt was already a retry, so let's stop here + $this->debug("Request retry failed. Won't retry again"); + throw $e; + } + + if ($this->getConfiguration()->readOption('disable_auto_retry')) { + // this attempt was already a retry, so let's stop here + $this->debug("Re-logging in disabled. Won't retry"); + throw $e; + } + + $this->debug("401 Unauthorized exception returned"); + $this->debug("Logging in again and retrying request"); + // see if logging in again and retrying the request works + $this->Login(); + + return $this->request($capability, $options, true); } $response = new \PHRETS\Http\Response($response); @@ -352,20 +388,46 @@ protected function request($capability, $options = []) } } - if (preg_match('/text\/xml/', $response->getHeader('Content-Type')) and $capability != 'GetObject') { + $this->debug('Response: HTTP ' . $response->getStatusCode()); + + if (stripos($response->getHeader('Content-Type'), 'text/xml') !== false and $capability != 'GetObject') { $parser = $this->grab(Strategy::PARSER_XML); $xml = $parser->parse($response); + if ($xml and isset($xml['ReplyCode'])) { $rc = (string)$xml['ReplyCode']; + + if ($rc == "20037" and $capability != 'Login') { + // must make Login request again. let's handle this automatically + + if ($this->getConfiguration()->readOption('disable_auto_retry')) { + // this attempt was already a retry, so let's stop here + $this->debug("Re-logging in disabled. Won't retry"); + throw new RETSException($xml['ReplyText'], (int)$xml['ReplyCode']); + } + + if ($is_retry) { + // this attempt was already a retry, so let's stop here + $this->debug("Request retry failed. Won't retry again"); + // let this error fall through to the more generic handling below + } else { + $this->debug("RETS 20037 re-auth requested"); + $this->debug("Logging in again and retrying request"); + // see if logging in again and retrying the request works + $this->Login(); + + return $this->request($capability, $options, true); + } + } + // 20201 - No records found - not exception worthy in my mind // 20403 - No objects found - not exception worthy in my mind - if ($rc != "0" and $rc != "20201" and $rc != "20403") { + if (!in_array($rc, [0, 20201, 20403])) { throw new RETSException($xml['ReplyText'], (int)$xml['ReplyCode']); } } } - $this->debug('Response: HTTP ' . $response->getStatusCode()); return $response; } diff --git a/src/Strategies/StandardStrategy.php b/src/Strategies/StandardStrategy.php index d632aee..8c4a419 100644 --- a/src/Strategies/StandardStrategy.php +++ b/src/Strategies/StandardStrategy.php @@ -20,7 +20,7 @@ class StandardStrategy implements Strategy Strategy::PARSER_METADATA_RESOURCE => \PHRETS\Parsers\GetMetadata\Resource::class, Strategy::PARSER_METADATA_CLASS => \PHRETS\Parsers\GetMetadata\ResourceClass::class, Strategy::PARSER_METADATA_TABLE => \PHRETS\Parsers\GetMetadata\Table::class, - Strategy::PARSER_METADATA_OBJECT => \PHRETS\Parsers\GetMetadata\Object::class, + Strategy::PARSER_METADATA_OBJECT => \PHRETS\Parsers\GetMetadata\BaseObject::class, Strategy::PARSER_METADATA_LOOKUPTYPE => \PHRETS\Parsers\GetMetadata\LookupType::class, Strategy::PARSER_XML => \PHRETS\Parsers\XML::class, ]; diff --git a/tests/Http/ResponseTest.php b/tests/Http/ResponseTest.php new file mode 100644 index 0000000..3e1b8e8 --- /dev/null +++ b/tests/Http/ResponseTest.php @@ -0,0 +1,26 @@ +First NameLast Name"; + $guzzleResponse = new GuzzleHttp\Psr7\Response(200, ['X-Foo' => 'Bar'], $body); + + $response = new PHRETS\Http\Response($guzzleResponse); + + $this->assertEquals(1, $response->xml()->count()); + } + + /** @test **/ + public function it_creates_valid_xml_with_new_lines() + { + $body = "\n\n\rFirst NameLast Name\r\n\n"; + $guzzleResponse = new GuzzleHttp\Psr7\Response(200, ['X-Foo' => 'Bar'], $body); + + $response = new PHRETS\Http\Response($guzzleResponse); + + $this->assertEquals(1, $response->xml()->count()); + } +} diff --git a/tests/Integration/BaseIntegration.php b/tests/Integration/BaseIntegration.php index ad010fe..d4dc99b 100644 --- a/tests/Integration/BaseIntegration.php +++ b/tests/Integration/BaseIntegration.php @@ -28,6 +28,7 @@ public function setUp() $watcher = new Gsaulmon\GuzzleRecorder\GuzzleRecorder(__DIR__ . '/Fixtures/Http'); $watcher->addIgnoredHeader('Accept'); + $watcher->addIgnoredHeader('User-Agent'); $watcher->addIgnoredHeader('Cookie'); $watcher->attach_to($new_client); diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/action_rets2_1_Action/c137023b38529b645fb39f8ad8279cd2.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/action_rets2_1_Action/d5d441322368e5c2ad059621979b0d88.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/action_rets2_1_Action/c137023b38529b645fb39f8ad8279cd2.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/action_rets2_1_Action/d5d441322368e5c2ad059621979b0d88.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/action_rets2_1_Login/5f7f2002a41ef7e295cfafd7761604d6.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/action_rets2_1_Login/03cd0f6cb206f18aed8f4979939a9482.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/action_rets2_1_Login/5f7f2002a41ef7e295cfafd7761604d6.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/action_rets2_1_Login/03cd0f6cb206f18aed8f4979939a9482.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/limited_rets2_1_Login/68c849d40907d376c5153ca76ab1d634.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/limited_rets2_1_Login/d848b86daf1f828cdf637404afc72626.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/limited_rets2_1_Login/68c849d40907d376c5153ca76ab1d634.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/limited_rets2_1_Login/d848b86daf1f828cdf637404afc72626.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/lookup_rets2_1_GetMetadata/bd570d3244346c277957e9dc9ce96fc8.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/lookup_rets2_1_GetMetadata/9d3ab35ecd3b097760867c2d7259ed83.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/lookup_rets2_1_GetMetadata/bd570d3244346c277957e9dc9ce96fc8.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/lookup_rets2_1_GetMetadata/9d3ab35ecd3b097760867c2d7259ed83.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/lookup_rets2_1_Login/57224dadb1ad87b8f1bd78a01e7df105.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/lookup_rets2_1_Login/e057db12dc3a7f37caa2203ecc2fe13e.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/lookup_rets2_1_Login/57224dadb1ad87b8f1bd78a01e7df105.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/lookup_rets2_1_Login/e057db12dc3a7f37caa2203ecc2fe13e.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/a119a87749b5f4b78b7dfe5b75fc5633.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/0c110d39a7815a91b58a68006aa42dbf.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/a119a87749b5f4b78b7dfe5b75fc5633.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/0c110d39a7815a91b58a68006aa42dbf.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/705cd7b6d6d27671d294262498e8ea9e.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/3f61a38b92bfdb51eaf133bf516b2483.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/705cd7b6d6d27671d294262498e8ea9e.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/3f61a38b92bfdb51eaf133bf516b2483.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/9161d31000e27336c1b3b62820d9d365.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/4f4529540496ce9bc194500a6d109a2c.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/9161d31000e27336c1b3b62820d9d365.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/4f4529540496ce9bc194500a6d109a2c.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/379d895fdf3587f9e3879ca8c8cb40a1.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/785c884c29c4c4d17deb0fcd89cd5282.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/379d895fdf3587f9e3879ca8c8cb40a1.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/785c884c29c4c4d17deb0fcd89cd5282.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/a33b15858edd47a185f6f221df597a92.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/940a2bcb4240708a30ed3e4abd2a3056.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/a33b15858edd47a185f6f221df597a92.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/940a2bcb4240708a30ed3e4abd2a3056.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/dc95b8e6f7ce96e7a84dec6c571895ab.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/9d194ccfcc9edb5a93dea267d1f9c91d.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/dc95b8e6f7ce96e7a84dec6c571895ab.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/9d194ccfcc9edb5a93dea267d1f9c91d.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/ae3834bdb8c3dd003ba4c4a8c48baf3e.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/9ed93625ec4cad577e42158701ae7b44.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/ae3834bdb8c3dd003ba4c4a8c48baf3e.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/9ed93625ec4cad577e42158701ae7b44.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/7c63f0c3acee0a8ca156b41299f9ed70.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/b3a4345b713492d24315d1f92665d7a6.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/7c63f0c3acee0a8ca156b41299f9ed70.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/b3a4345b713492d24315d1f92665d7a6.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/001eb002b7463e2bc06a044733411ca2.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/bbe857812f04d9e40c3508c212ab0ebe.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/001eb002b7463e2bc06a044733411ca2.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetMetadata/bbe857812f04d9e40c3508c212ab0ebe.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/ba551e44d6528c00ab5316c22d9b2333.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/204749e19efea78e43edf1f3333ee44b.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/ba551e44d6528c00ab5316c22d9b2333.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/204749e19efea78e43edf1f3333ee44b.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/f6845defd645868b92e6334220bf1033.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/27e68249f6feeb17925a7af12c75e3e9.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/f6845defd645868b92e6334220bf1033.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/27e68249f6feeb17925a7af12c75e3e9.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/932d1b74540ce51a9c52eb5991f8d32e.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/bc184498e2ca6712c7c2e8f5a4cec90e.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/932d1b74540ce51a9c52eb5991f8d32e.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_GetObject/bc184498e2ca6712c7c2e8f5a4cec90e.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/5826ab498becc30e0b4bdfc76fd446eb.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/aaae3d614d1660701f3d7508efb11004.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/5826ab498becc30e0b4bdfc76fd446eb.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/aaae3d614d1660701f3d7508efb11004.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/e604e7ffd22cf87f27243e1447be9a6e.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/ac1f434b220d1920fa87a27d582bc877.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/e604e7ffd22cf87f27243e1447be9a6e.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/ac1f434b220d1920fa87a27d582bc877.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/b0c026e533aab116e08ea714815d0e22.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/e5df43b61e717bc8e3d4759aad894e2f.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/b0c026e533aab116e08ea714815d0e22.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Login/e5df43b61e717bc8e3d4759aad894e2f.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Logout/38a4125fc6d66ec797b2d99573ab4ba9.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Logout/18f6b7bfb97630b9cdbfd8af1b817310.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Logout/38a4125fc6d66ec797b2d99573ab4ba9.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Logout/18f6b7bfb97630b9cdbfd8af1b817310.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/afa92fb5f24842390c8f6cd6a99bb001.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/1aa3b4454404b11492369cc3f2b95e8f.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/afa92fb5f24842390c8f6cd6a99bb001.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/1aa3b4454404b11492369cc3f2b95e8f.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/0f0673d2ef2a477d342a7a0437289f2a.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/5836410b43446216e8b33c787d798441.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/0f0673d2ef2a477d342a7a0437289f2a.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/5836410b43446216e8b33c787d798441.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/393e7f69f016ec9997893ddf90d8fbbf.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/71fb8c90d106cf1f88c5687044918787.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/393e7f69f016ec9997893ddf90d8fbbf.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/71fb8c90d106cf1f88c5687044918787.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/57e666dcbb001b95fe6ce5cc6b50f9c6.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/7580aa7ffcd519406def9899f7efbb41.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/57e666dcbb001b95fe6ce5cc6b50f9c6.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/7580aa7ffcd519406def9899f7efbb41.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/ab7c6098ce63dacbf763ae6a39eba7f8.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/772dbb6548885978fd7b656175e0b817.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/ab7c6098ce63dacbf763ae6a39eba7f8.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/772dbb6548885978fd7b656175e0b817.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/1e854d81ef520df4a3789556943739a7.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/77bebac441fa391975e56cb720f2d7e7.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/1e854d81ef520df4a3789556943739a7.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/77bebac441fa391975e56cb720f2d7e7.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/5cde31d395414b0591f8ddf919ac15c2.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/90471d12722b9f16e7568920b861cf1f.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/5cde31d395414b0591f8ddf919ac15c2.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/90471d12722b9f16e7568920b861cf1f.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/da959b0ae1504119844e6c4cb9677b80.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/c0296526b8e1e8954a8001dbb85b01ea.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/da959b0ae1504119844e6c4cb9677b80.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/c0296526b8e1e8954a8001dbb85b01ea.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/b012748c0e118d0b39a6636107f0f1d5.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/e9f250f06854ab0e94b017681e91c7bd.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/b012748c0e118d0b39a6636107f0f1d5.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/e9f250f06854ab0e94b017681e91c7bd.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/46f251b82fcb364d35c361bd96fc61f6.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/f065035031b4ce43d3e5374517306e20.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/46f251b82fcb364d35c361bd96fc61f6.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/f065035031b4ce43d3e5374517306e20.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/60f1a0663d376a146a8c9bfc1619c612.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/f07c8bc25411e40b67847cef66883ab5.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/60f1a0663d376a146a8c9bfc1619c612.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/f07c8bc25411e40b67847cef66883ab5.txt diff --git a/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/b8fa19ea891acc0542e40873643f8656.txt b/tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/f32d4206aad8af73adadb03e5b066e0e.txt similarity index 100% rename from tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/b8fa19ea891acc0542e40873643f8656.txt rename to tests/Integration/Fixtures/Http/get/retsgw.flexmls.com/rets2_1_Search/f32d4206aad8af73adadb03e5b066e0e.txt diff --git a/tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_GetMetadata/3db9d8ee35ba1b9435e9d6ca037c1616.txt b/tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_GetMetadata/1af5d18d3171486377f6fe6c09cda258.txt similarity index 100% rename from tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_GetMetadata/3db9d8ee35ba1b9435e9d6ca037c1616.txt rename to tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_GetMetadata/1af5d18d3171486377f6fe6c09cda258.txt diff --git a/tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_Login/ec520b6cefeb5cbeef8f44437ad3949d.txt b/tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_Login/57b9c3a515cb43d1141653c3f1395981.txt similarity index 100% rename from tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_Login/ec520b6cefeb5cbeef8f44437ad3949d.txt rename to tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_Login/57b9c3a515cb43d1141653c3f1395981.txt diff --git a/tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_Search/e27485932867c790503de2bfeb86ec2d.txt b/tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_Search/7dcdeb3bc5ff839b94836fb3ec2ff947.txt similarity index 100% rename from tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_Search/e27485932867c790503de2bfeb86ec2d.txt rename to tests/Integration/Fixtures/Http/post/retsgw.flexmls.com/rets2_1_Search/7dcdeb3bc5ff839b94836fb3ec2ff947.txt diff --git a/tests/Integration/GetMetadataIntegrationTest.php b/tests/Integration/GetMetadataIntegrationTest.php index c607e53..c2eaf81 100644 --- a/tests/Integration/GetMetadataIntegrationTest.php +++ b/tests/Integration/GetMetadataIntegrationTest.php @@ -192,7 +192,7 @@ public function it_gets_object_metadata() public function it_gets_keyed_object_metadata() { $object_types = $this->session->GetObjectMetadata('Property'); - $this->assertInstanceOf('\PHRETS\Models\Metadata\Object', $object_types['Photo']); + $this->assertInstanceOf('\PHRETS\Models\Metadata\BaseObject', $object_types['Photo']); } /** diff --git a/tests/Integration/GetObjectIntegrationTest.php b/tests/Integration/GetObjectIntegrationTest.php index 050e577..5d8d546 100644 --- a/tests/Integration/GetObjectIntegrationTest.php +++ b/tests/Integration/GetObjectIntegrationTest.php @@ -20,7 +20,7 @@ public function it_fetches_primary_object() $primary = $objects->first(); $object = $this->session->GetPreferredObject('Property', 'Photo', '00-1669', 1); - $this->assertTrue($object instanceof \PHRETS\Models\Object); + $this->assertTrue($object instanceof \PHRETS\Models\BaseObject); $this->assertEquals($primary, $object); } @@ -37,7 +37,7 @@ public function it_sees_locations_despite_xml_being_returned() $object = $this->session->GetObject('Property', 'Photo', 'URLS-WITH-XML', '*', 1); $this->assertCount(1, $object); - /** @var \PHRETS\Models\Object $first */ + /** @var \PHRETS\Models\BaseObject $first */ $first = $object->first(); $this->assertFalse($first->isError()); $this->assertSame('http://someurl', $first->getLocation()); diff --git a/tests/Models/ObjectTest.php b/tests/Models/ObjectTest.php index 3fdd534..a2e0ceb 100644 --- a/tests/Models/ObjectTest.php +++ b/tests/Models/ObjectTest.php @@ -1,13 +1,13 @@ setContent('Test Content'); $this->assertSame('Test Content', $o->getContent()); @@ -16,7 +16,7 @@ public function it_holds() /** @test **/ public function it_returns_a_size() { - $o = new Object; + $o = new BaseObject; $o->setContent('Hello'); $this->assertSame(5, $o->getSize()); @@ -35,7 +35,7 @@ public function it_makes_from_headers() 'MIME-Version' => 'Mime Version', ]; - $o = new Object; + $o = new BaseObject; foreach ($headers as $k => $v) { $o->setFromHeader($k, $v); } @@ -52,7 +52,7 @@ public function it_makes_from_headers() /** @test **/ public function it_marks_preferred_objects() { - $o = new Object; + $o = new BaseObject; $this->assertFalse($o->isPreferred()); $o->setPreferred(1); $this->assertTrue($o->isPreferred()); @@ -66,7 +66,7 @@ public function it_marks_errors() $e->setCode(1234); $e->setMessage('Test Error Message'); - $o = new Object; + $o = new BaseObject; $this->assertFalse($o->isError()); $o->setError($e); $this->assertTrue($o->isError()); diff --git a/tests/Parsers/GetObject/MultipleTest.php b/tests/Parsers/GetObject/MultipleTest.php index 6c304ee..9cfeaeb 100644 --- a/tests/Parsers/GetObject/MultipleTest.php +++ b/tests/Parsers/GetObject/MultipleTest.php @@ -40,7 +40,7 @@ public function it_breaks_things_apart() $this->assertSame(5, $collection->count()); - /** @var PHRETS\Models\Object $obj */ + /** @var PHRETS\Models\BaseObject $obj */ $obj = $collection->first(); $this->assertSame('Exterior Main View', $obj->getContentDescription()); $this->assertSame('http://url1.jpg', $obj->getLocation()); @@ -88,7 +88,7 @@ public function it_handles_unquoted_boundaries() $this->assertSame(5, $collection->count()); - /** @var PHRETS\Models\Object $obj */ + /** @var PHRETS\Models\BaseObject $obj */ $obj = $collection->first(); $this->assertSame('Exterior Main View', $obj->getContentDescription()); $this->assertSame('http://url1.jpg', $obj->getLocation());