From 44977088a85611b5606d3f290ec338e5fc1d8065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Wed, 9 Sep 2020 23:55:42 +0200 Subject: [PATCH] #4 - Error response parser fix --- .../installed-by-dh_install | 274 ----- src/FlexiPeeHP/FlexiBeeRO.php | 75 +- src/FlexiPeeHP/FlexiBeeRW.php | 203 +-- testing/FlexiPeeHP/FlexiBeeROTest.php | 1083 +++++++++++++++++ testing/src/FlexiPeeHP/FlexiBeeROTest.php | 580 ++++----- testing/src/FlexiPeeHP/FlexiBeeRWTest.php | 148 +-- 6 files changed, 1540 insertions(+), 823 deletions(-) delete mode 100644 debian/.debhelper/generated/php-spojenet-flexibee/installed-by-dh_install create mode 100644 testing/FlexiPeeHP/FlexiBeeROTest.php diff --git a/debian/.debhelper/generated/php-spojenet-flexibee/installed-by-dh_install b/debian/.debhelper/generated/php-spojenet-flexibee/installed-by-dh_install deleted file mode 100644 index 083a32d6..00000000 --- a/debian/.debhelper/generated/php-spojenet-flexibee/installed-by-dh_install +++ /dev/null @@ -1,274 +0,0 @@ -./src/FlexiPeeHP/Actions.php -./src/FlexiPeeHP/Adresar.php -./src/FlexiPeeHP/Banka.php -./src/FlexiPeeHP/Cenik.php -./src/FlexiPeeHP/Changes.php -./src/FlexiPeeHP/Company.php -./src/FlexiPeeHP/DodavatelskaSmlouva.php -./src/FlexiPeeHP/Evidence.php -./src/FlexiPeeHP/EvidenceList.php -./src/FlexiPeeHP/FakturaPrijata.php -./src/FlexiPeeHP/FakturaVydana.php -./src/FlexiPeeHP/FakturaVydanaPolozka.php -./src/FlexiPeeHP/Firma.php -./src/FlexiPeeHP/FlexiBeeRO.php -./src/FlexiPeeHP/FlexiBeeRW.php -./src/FlexiPeeHP/Formats.php -./src/FlexiPeeHP/Hooks.php -./src/FlexiPeeHP/InterniDoklad.php -./src/FlexiPeeHP/Kontakt.php -./src/FlexiPeeHP/Nastaveni.php -./src/FlexiPeeHP/Pokladna.php -./src/FlexiPeeHP/PokladniPohyb.php -./src/FlexiPeeHP/Priloha.php -./src/FlexiPeeHP/RadaPokladniPohyb.php -./src/FlexiPeeHP/Relations.php -./src/FlexiPeeHP/Report.php -./src/FlexiPeeHP/SkladovaKarta.php -./src/FlexiPeeHP/SkladovyPohyb.php -./src/FlexiPeeHP/SkladovyPohybPolozka.php -./src/FlexiPeeHP/SkupinaFirem.php -./src/FlexiPeeHP/Smlouva.php -./src/FlexiPeeHP/Status.php -./src/FlexiPeeHP/Stitek.php -./src/FlexiPeeHP/Stitky.php -./src/FlexiPeeHP/Strom.php -./src/FlexiPeeHP/StromCenik.php -./src/FlexiPeeHP/SubItems.php -./src/FlexiPeeHP/Sum.php -./src/FlexiPeeHP/UcetniObdobi.php -./src/FlexiPeeHP/VyrobniCislo.php -./src/FlexiPeeHP/Zavazek.php -./src/FlexiPeeHP/Zurnal.php -./debian/composer.json -./static/Actions.json -./static/EvidenceFullList.json -./static/EvidenceList.json -./static/Formats.json -./static/Properties.adresar-bankovni-ucet.json -./static/Properties.adresar.json -./static/Properties.analyza-nakupu.json -./static/Properties.analyza-prodeje.json -./static/Properties.analyza-zakazky.json -./static/Properties.atribut.json -./static/Properties.banka-polozka.json -./static/Properties.banka.json -./static/Properties.bankovni-ucet.json -./static/Properties.cenik-obal.json -./static/Properties.cenik.json -./static/Properties.cenikova-skupina.json -./static/Properties.cenikovy-pohyb-nakup.json -./static/Properties.cenikovy-pohyb-prodej.json -./static/Properties.cenova-uroven.json -./static/Properties.certifikacni-autorita.json -./static/Properties.certifikat-eet.json -./static/Properties.cinnost.json -./static/Properties.ciselnik-mzdovych-slozek.json -./static/Properties.cislo-baliku.json -./static/Properties.cleneni-dph.json -./static/Properties.cleneni-kontrolni-hlaseni.json -./static/Properties.custom-button.json -./static/Properties.danova-evidence.json -./static/Properties.dashboard-panel.json -./static/Properties.dashboard-sharing.json -./static/Properties.dite.json -./static/Properties.dodavatel.json -./static/Properties.dodavatelska-smlouva.json -./static/Properties.dodavatelsky-typ-smlouvy.json -./static/Properties.doklad-k-uhrade.json -./static/Properties.doklad.json -./static/Properties.eet-komunikace.json -./static/Properties.faktura-prijata-polozka.json -./static/Properties.faktura-prijata.json -./static/Properties.faktura-vydana-polozka.json -./static/Properties.faktura-vydana.json -./static/Properties.filtr.json -./static/Properties.forma-dopravy.json -./static/Properties.forma-uhrady-zauctovani.json -./static/Properties.forma-uhrady.json -./static/Properties.format-elektronickeho-bankovnictvi.json -./static/Properties.hlavni-kniha.json -./static/Properties.hodnoceni-zakazky.json -./static/Properties.individualni-cenik.json -./static/Properties.insight.json -./static/Properties.interni-doklad-polozka.json -./static/Properties.interni-doklad.json -./static/Properties.intrastat-dodaci-podminky.json -./static/Properties.intrastat-druh-dopravy.json -./static/Properties.intrastat-kod-nomenklatury.json -./static/Properties.intrastat-kraj-urceni.json -./static/Properties.intrastat-kurz.json -./static/Properties.intrastat-merna-jednotka.json -./static/Properties.intrastat-obchodni-transakce.json -./static/Properties.intrastat-zvlastni-pohyb.json -./static/Properties.inventura-polozka.json -./static/Properties.inventura.json -./static/Properties.konst-symbol.json -./static/Properties.kontakt.json -./static/Properties.kurz-pro-cenotvorbu.json -./static/Properties.kurz.json -./static/Properties.leasing.json -./static/Properties.majetek-udalost.json -./static/Properties.majetek.json -./static/Properties.mapovani-skladu.json -./static/Properties.mena.json -./static/Properties.merna-jednotka.json -./static/Properties.misto-urceni.json -./static/Properties.mzda.json -./static/Properties.mzdova-slozka.json -./static/Properties.mzdy-bankovni-spojeni.json -./static/Properties.nabidka-prijata-polozka.json -./static/Properties.nabidka-prijata.json -./static/Properties.nabidka-vydana-polozka.json -./static/Properties.nabidka-vydana.json -./static/Properties.naklad.json -./static/Properties.nastaveni.json -./static/Properties.nepritomnost.json -./static/Properties.objednavka-prijata-polozka.json -./static/Properties.objednavka-prijata.json -./static/Properties.objednavka-vydana-polozka.json -./static/Properties.objednavka-vydana.json -./static/Properties.obrat.json -./static/Properties.obratova-predvaha.json -./static/Properties.odberatel.json -./static/Properties.odpisova-skupina.json -./static/Properties.osoba-hlavicka.json -./static/Properties.osoba.json -./static/Properties.parametr.json -./static/Properties.penezni-ustav.json -./static/Properties.podklady-dph.json -./static/Properties.podobne-zbozi.json -./static/Properties.pohledavka-polozka.json -./static/Properties.pohledavka.json -./static/Properties.pohyb-na-uctech.json -./static/Properties.pokladna.json -./static/Properties.pokladni-pohyb-polozka.json -./static/Properties.pokladni-pohyb.json -./static/Properties.poplatek.json -./static/Properties.poptavka-prijata-polozka.json -./static/Properties.poptavka-prijata.json -./static/Properties.poptavka-vydana-polozka.json -./static/Properties.poptavka-vydana.json -./static/Properties.prace-mesic.json -./static/Properties.prace.json -./static/Properties.pracovni-pomer-hlavicka.json -./static/Properties.pracovni-pomer.json -./static/Properties.pravo-viditelnosti.json -./static/Properties.predpis-zauctovani.json -./static/Properties.prehled-zamestnancu.json -./static/Properties.preneseni-dph.json -./static/Properties.prikaz-k-inkasu-polozka.json -./static/Properties.prikaz-k-inkasu.json -./static/Properties.prikaz-k-uhrade-polozka.json -./static/Properties.prikaz-k-uhrade.json -./static/Properties.priloha.json -./static/Properties.prislustenstvi.json -./static/Properties.prodejka-platba.json -./static/Properties.prodejka.json -./static/Properties.psc.json -./static/Properties.rada-banka.json -./static/Properties.rada-faktury-prijate.json -./static/Properties.rada-faktury-vydane.json -./static/Properties.rada-interniho-dokladu.json -./static/Properties.rada-nabidky-prijate.json -./static/Properties.rada-nabidky-vydane.json -./static/Properties.rada-objednavky-prijate.json -./static/Properties.rada-objednavky-vydane.json -./static/Properties.rada-pohledavky.json -./static/Properties.rada-pokladni-pohyb.json -./static/Properties.rada-poptavky-prijate.json -./static/Properties.rada-poptavky-vydane.json -./static/Properties.rada-skladovy-pohyb.json -./static/Properties.rada-zavazku.json -./static/Properties.rada.json -./static/Properties.radek-priznani-dph.json -./static/Properties.rezervace.json -./static/Properties.rocni-rada.json -./static/Properties.rozvaha-po-uctech.json -./static/Properties.sablona-upominky.json -./static/Properties.sady-a-komplety.json -./static/Properties.saldo-k-datu.json -./static/Properties.saldo.json -./static/Properties.sazba-dph.json -./static/Properties.setting-store.json -./static/Properties.sklad.json -./static/Properties.skladova-karta.json -./static/Properties.skladovy-pohyb-polozka.json -./static/Properties.skladovy-pohyb.json -./static/Properties.skupina-atributu.json -./static/Properties.skupina-firem.json -./static/Properties.skupina-osob.json -./static/Properties.skupina-stitku.json -./static/Properties.skupina-zbozi.json -./static/Properties.smena.json -./static/Properties.smlouva-polozka.json -./static/Properties.smlouva.json -./static/Properties.srazka.json -./static/Properties.stala-mzdova-slozka.json -./static/Properties.stat.json -./static/Properties.stav-ceniku.json -./static/Properties.stav-skladu-k-datu.json -./static/Properties.stav-smlouvy.json -./static/Properties.stav-uctu.json -./static/Properties.stav-zakazky.json -./static/Properties.stitek.json -./static/Properties.stredisko.json -./static/Properties.strom-cenik.json -./static/Properties.strom-koren.json -./static/Properties.strom.json -./static/Properties.subjekt.json -./static/Properties.text.json -./static/Properties.typ-aktivity.json -./static/Properties.typ-atributu.json -./static/Properties.typ-banka.json -./static/Properties.typ-faktury-prijate.json -./static/Properties.typ-faktury-vydane.json -./static/Properties.typ-interniho-dokladu.json -./static/Properties.typ-leasingu.json -./static/Properties.typ-majetku.json -./static/Properties.typ-nabidky-prijate.json -./static/Properties.typ-nabidky-vydane.json -./static/Properties.typ-nakladu.json -./static/Properties.typ-objednavky-prijate.json -./static/Properties.typ-objednavky-vydane.json -./static/Properties.typ-organizace.json -./static/Properties.typ-pohledavky.json -./static/Properties.typ-pokladni-pohyb.json -./static/Properties.typ-poptavky-prijate.json -./static/Properties.typ-poptavky-vydane.json -./static/Properties.typ-pracovniho-pomeru.json -./static/Properties.typ-prodejky.json -./static/Properties.typ-skladovy-pohyb.json -./static/Properties.typ-smlouvy.json -./static/Properties.typ-stavu-ceniku.json -./static/Properties.typ-uzivatelske-vazby.json -./static/Properties.typ-vzajemnych-zapoctu.json -./static/Properties.typ-zakazky.json -./static/Properties.typ-zavazku.json -./static/Properties.ucet.json -./static/Properties.ucetni-denik.json -./static/Properties.ucetni-obdobi.json -./static/Properties.ucetni-osnova.json -./static/Properties.udalost.json -./static/Properties.umisteni-ve-skladu-mistnost.json -./static/Properties.umisteni-ve-skladu-police.json -./static/Properties.umisteni-ve-skladu-regal.json -./static/Properties.umisteni-ve-skladu.json -./static/Properties.umisteni.json -./static/Properties.uzivatel.json -./static/Properties.uzivatelska-vazba.json -./static/Properties.uzivatelsky-dotaz-parametr.json -./static/Properties.uzivatelsky-dotaz-vlastnost.json -./static/Properties.uzivatelsky-dotaz.json -./static/Properties.vazba.json -./static/Properties.vazebni-doklad.json -./static/Properties.vykaz-hospodareni.json -./static/Properties.vyrobni-cislo.json -./static/Properties.vzajemny-zapocet.json -./static/Properties.xslt.json -./static/Properties.zakazka.json -./static/Properties.zapujcka.json -./static/Properties.zavazek-polozka.json -./static/Properties.zavazek.json -./static/Properties.zurnal.json -./static/Relations.json diff --git a/src/FlexiPeeHP/FlexiBeeRO.php b/src/FlexiPeeHP/FlexiBeeRO.php index 0fae252b..a4bacb1c 100644 --- a/src/FlexiPeeHP/FlexiBeeRO.php +++ b/src/FlexiPeeHP/FlexiBeeRO.php @@ -4,7 +4,7 @@ * FlexiPeeHP - Read Only Access to FlexiBee class. * * @author Vítězslav Dvořák - * @copyright (C) 2015-2019 Spoje.Net + * @copyright (C) 2015-2020 Spoje.Net */ namespace FlexiPeeHP; @@ -32,7 +32,6 @@ class FlexiBeeRO extends \Ease\Sand { public static $libVersion = '1.37'; /** - * Základní namespace pro komunikaci s FlexiBee. * Basic namespace for communication with FlexiBee * * @var string Jmený prostor datového bloku odpovědi @@ -46,7 +45,6 @@ class FlexiBeeRO extends \Ease\Sand { public $apiURL = null; /** - * Datový blok v poli odpovědi. * Data block in response field. * * @var string @@ -54,7 +52,6 @@ class FlexiBeeRO extends \Ease\Sand { public $resultField = 'results'; /** - * Verze protokolu použitého pro komunikaci. * Communication protocol version used. * * @var string Verze použitého API @@ -62,10 +59,10 @@ class FlexiBeeRO extends \Ease\Sand { public $protoVersion = '1.0'; /** - * Evidence užitá objektem. * Evidence used by object * * @link https://demo.flexibee.eu/c/demo/evidence-list Přehled evidencí + * * @var string */ public $evidence = null; @@ -78,7 +75,6 @@ class FlexiBeeRO extends \Ease\Sand { public $evidenceInfo = []; /** - * Výchozí formát pro komunikaci. * Default communication format. * * @link https://www.flexibee.eu/api/dokumentace/ref/format-types Přehled možných formátů @@ -88,8 +84,7 @@ class FlexiBeeRO extends \Ease\Sand { public $format = 'json'; /** - * formát příchozí odpovědi - * response format + * requested response format * * @link https://www.flexibee.eu/api/dokumentace/ref/format-types Přehled možných formátů * @@ -131,7 +126,7 @@ class FlexiBeeRO extends \Ease\Sand { /** * @var array Pole HTTP hlaviček odesílaných s každým požadavkem */ - public $defaultHttpHeaders = ['User-Agent' => 'FlexiPeeHP']; + public $defaultHttpHeaders = []; /** * Default additional request url parameters after question mark @@ -231,7 +226,7 @@ class FlexiBeeRO extends \Ease\Sand { * * @var string */ - protected $postFields = null; + public $postFields = null; /** * Last operation result data or message(s) @@ -344,7 +339,7 @@ class FlexiBeeRO extends \Ease\Sand { * Array of errors caused by last request * @var array */ - private $errors = []; + protected $errors = []; /** * List of Error500 reports sent @@ -558,25 +553,27 @@ public function configToEnv($opts = null) { public function curlInit() { if ($this->offline === false) { $this->curl = \curl_init(); // create curl resource - curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true); // return content as a string from curl_exec - curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true); // follow redirects (compatibility for future changes in FlexiBee) - curl_setopt($this->curl, CURLOPT_HTTPAUTH, true); // HTTP authentication - curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false); // FlexiBee by default uses Self-Signed certificates - curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($this->curl, CURLOPT_VERBOSE, ($this->debug === true)); // For debugging + \curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true); // return content as a string from curl_exec + \curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true); // follow redirects (compatibility for future changes in FlexiBee) + \curl_setopt($this->curl, CURLOPT_HTTPAUTH, true); // HTTP authentication + \curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false); // FlexiBee by default uses Self-Signed certificates + \curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false); + \curl_setopt($this->curl, CURLOPT_VERBOSE, ($this->debug === true)); // For debugging if (empty($this->authSessionId)) { - curl_setopt($this->curl, CURLOPT_USERPWD, + \curl_setopt($this->curl, CURLOPT_USERPWD, $this->user . ':' . $this->password); // set username and password } if (!is_null($this->timeout)) { - curl_setopt($this->curl, CURLOPT_TIMEOUT, $this->timeout); + \curl_setopt($this->curl, CURLOPT_TIMEOUT, $this->timeout); } + + \curl_setopt($this->curl, CURLOPT_USERAGENT, 'phpFlexiBee v' . self::$libVersion . ' https://github.com/Spoje-NET/php-flexibee'); } return !$this->offline; } /** - * Zinicializuje objekt dle daných dat. Možné hodnoty: + * Initialise object with given data. Availble value types: * * * 234 - interní číslo záznamu k načtení * * code:LOPATA - kód záznamu @@ -1076,27 +1073,10 @@ public function parseResponse($responseDecoded, $responseCode) { * @return int number of errors processed */ public function parseError(array $responseDecoded) { - if (array_key_exists('results', $responseDecoded)) { - - foreach ($responseDecoded['results'][0]['result'] as $result) { - if (array_key_exists('errors', $result)) { - foreach ($result as $error) { - $this->errors[] = current($error); - } - } - } - - foreach ($this->errors as $errorInfo) { - $this->addStatusMessage(array_key_exists('error', $errorInfo) ? $errorInfo['error'] : $errorInfo['message'], 'error'); - if (array_key_exists('for', $errorInfo)) { - unset($errorInfo['message']); - $this->addStatusMessage(json_encode($errorInfo), 'debug'); - } - } + if (array_key_exists('success', $responseDecoded)) { + $this->errors = [['message' => array_key_exists('message', $responseDecoded) ? $responseDecoded['message'] : '']]; } else { - if (array_key_exists('message', $responseDecoded)) { - $this->errors = [['message' => $responseDecoded['message']]]; - } + throw new \Ease\Exception('Unparsed error: ' . $this->lastCurlResponse); } return count($this->errors); } @@ -1131,21 +1111,15 @@ public function doCurlRequest($url, $method, $format = null) { if (!isset($httpHeaders['Content-Type'])) { $httpHeaders['Content-Type'] = $formats[$format]['content-type']; } - $httpHeadersFinal = []; - foreach ($httpHeaders as $key => $value) { - if (($key == 'User-Agent') && ($value == 'FlexiPeeHP')) { - $value .= ' v' . self::$libVersion; - } - $httpHeadersFinal[] = $key . ': ' . $value; - } - curl_setopt($this->curl, CURLOPT_HTTPHEADER, $httpHeadersFinal); + array_walk($httpHeaders, function (&$value,$header) { $value = $header .': '.$value; } ); + curl_setopt($this->curl, CURLOPT_HTTPHEADER, $httpHeaders); // Proveď samotnou operaci $this->lastCurlResponse = curl_exec($this->curl); $this->curlInfo = curl_getinfo($this->curl); $this->curlInfo['when'] = microtime(); - $this->curlInfo['request_headers'] = $httpHeadersFinal; + $this->curlInfo['request_headers'] = $httpHeaders; $this->responseFormat = $this->contentTypeToResponseFormat($this->curlInfo['content_type'], $url); $this->lastResponseCode = $this->curlInfo['http_code']; @@ -1158,7 +1132,6 @@ public function doCurlRequest($url, $method, $format = null) { if ($this->debug === true) { $this->saveDebugFiles(); } - return $this->lastResponseCode; } @@ -2356,7 +2329,7 @@ public function getFlexiBeeURL() { */ public function setMyKey($myKeyValue) { if (substr($myKeyValue, 0, 4) == 'ext:') { - if ($this->evidenceInfo['extIdSupported'] == 'false') { + if (empty($this->evidenceInfo) || ($this->evidenceInfo['extIdSupported'] == 'false')) { $this->addStatusMessage(sprintf(_('Evidence %s does not support extIDs'), $this->getEvidence()), 'warning'); $res = false; diff --git a/src/FlexiPeeHP/FlexiBeeRW.php b/src/FlexiPeeHP/FlexiBeeRW.php index 911f5a4a..5a53ee6b 100644 --- a/src/FlexiPeeHP/FlexiBeeRW.php +++ b/src/FlexiPeeHP/FlexiBeeRW.php @@ -1,4 +1,5 @@ atomic = (boolean) $options['atomic']; } @@ -84,13 +83,12 @@ public function setUp($options = array()) * * @return array odpověď */ - public function insertToFlexiBee($data = null) - { + public function insertToFlexiBee($data = null) { if (is_null($data)) { $data = $this->getData(); } $this->postFields = $this->getJsonizedData($data, - $this->debug ? JSON_PRETTY_PRINT : 0); + $this->debug ? JSON_PRETTY_PRINT : 0); return $this->performRequest(null, 'PUT'); } @@ -102,41 +100,83 @@ public function insertToFlexiBee($data = null) * * @return array main data part of response */ - public function parseResponse($responseDecoded, $responseCode) - { + public function parseResponse($responseDecoded, $responseCode) { $parsedData = parent::parseResponse($responseDecoded, $responseCode); switch ($responseCode) { case 201: //Success Write if (is_array($responseDecoded)) { $this->responseStats = array_key_exists('stats', - $responseDecoded) ? (isset($responseDecoded['stats'][0]) - ? array_map('intval', $responseDecoded['stats'][0]) : array_map('intval', $responseDecoded['stats'])) - : null; - if (isset($responseDecoded[$this->resultField][0]['id'])) { - $this->lastInsertedID = $responseDecoded[$this->resultField][0]['id']; - $this->setMyKey($this->lastInsertedID); - } else { - $this->lastInsertedID = null; - } - if (count($this->chained)) { - $this->assignResultIDs($this->extractResultIDs($responseDecoded[$this->resultField])); + $responseDecoded) ? (isset($responseDecoded['stats'][0]) ? array_map('intval', $responseDecoded['stats'][0]) : array_map('intval', $responseDecoded['stats'])) : null; + if (isset($responseDecoded[$this->resultField][0]['id'])) { + $this->lastInsertedID = $responseDecoded[$this->resultField][0]['id']; + $this->setMyKey($this->lastInsertedID); + } else { + $this->lastInsertedID = null; + } + if (count($this->chained)) { + $this->assignResultIDs($this->extractResultIDs($responseDecoded[$this->resultField])); + } } - } $parsedData = $responseDecoded['results']; } return $parsedData; } + /** + * Parse error message response + * + * @param array $responseDecoded + * + * @return int number of errors processed + */ + public function parseError(array $responseDecoded) { + if (array_key_exists('results', $responseDecoded)) { + + if (array_key_exists(0, $responseDecoded['results'])) { + foreach ($responseDecoded['results'] as $result) { + + if (array_key_exists('request-id', $result)) { + unset($result['request-id']); + } + + if (array_key_exists('errors', $result)) { + foreach ($result as $error) { + $this->errors[] = current($error); + } + } + } + } else { + foreach ($responseDecoded['results'][0]['result'] as $result) { + if (array_key_exists('errors', $result)) { + foreach ($result as $error) { + $this->errors[] = current($error); + } + } + } + } + + foreach ($this->errors as $errorInfo) { + $this->addStatusMessage(array_key_exists('error', $errorInfo) ? $errorInfo['error'] : $errorInfo['message'], 'error'); + if ($this->debug && array_key_exists('for', $errorInfo)) { + unset($errorInfo['message']); + $this->addStatusMessage(json_encode($errorInfo), 'debug'); + } + } + } else { + parent::parseError($responseDecoded); + } + return count($this->errors); + } + /** * Assign result IDs to its source objects * * @param array $candidates FlexiBee insert IDs prepared by extractResultIDs() */ - public function assignResultIDs($candidates) - { + public function assignResultIDs($candidates) { foreach ($this->chained as $chid => $chained) { $chainedEvidence = $chained->getEvidence(); - $chainedExtid = $chained->getRecordID(); + $chainedExtid = $chained->getRecordID(); if (is_array($chainedExtid)) { //if there are more IDs foreach ($chainedExtid as $extId) { //find external ID in format ext:..... if (stripos($extId, 'ext:') === 0) { @@ -163,8 +203,7 @@ public function assignResultIDs($candidates) * * @return array List of [ 'evidence1'=>[ 'original-id'=>numericID,'original-id2'=>numericID2 ], 'evidence2'=> ... ] */ - public function extractResultIDs($resultInfo) - { + public function extractResultIDs($resultInfo) { $candidates = []; foreach ($resultInfo as $insertResult) { $newID = $insertResult['id']; @@ -173,7 +212,7 @@ public function extractResultIDs($resultInfo) } else { $extid = null; } - $evidence = explode('/', $insertResult['ref'])[3]; + $evidence = explode('/', $insertResult['ref'])[3]; $candidates[$evidence][$extid] = $newID; } return $candidates; @@ -184,8 +223,7 @@ public function extractResultIDs($resultInfo) * * @return int */ - public function getLastInsertedId() - { + public function getLastInsertedId() { return $this->lastInsertedID; } @@ -197,14 +235,13 @@ public function getLastInsertedId() * * @return boolean Response code is 200 ? */ - public function deleteFromFlexiBee($id = null) - { + public function deleteFromFlexiBee($id = null) { if (is_null($id)) { $id = $this->getMyKey(); } - $this->performRequest($this->getEvidenceUrl().'/'.self::urlizeId($id), - 'DELETE'); + $this->performRequest($this->getEvidenceUrl() . '/' . self::urlizeId($id), + 'DELETE'); return $this->lastResponseCode == 200; } @@ -215,11 +252,10 @@ public function deleteFromFlexiBee($id = null) * * @return int number of records taken */ - public function takeData($data) - { + public function takeData($data) { if ($this->debug === true) { $fbRelations = []; - $fbColumns = $this->getColumnsInfo(); + $fbColumns = $this->getColumnsInfo(); foreach ($this->getRelationsInfo() as $relation) { if (is_array($relation) && isset($relation['url'])) { $fbRelations[$relation['url']] = $relation['url']; @@ -231,11 +267,11 @@ public function takeData($data) if (!array_key_exists($key, $fbRelations)) { $this->addStatusMessage(sprintf('unknown column %s for evidence %s', - $key, $this->getEvidence()), 'warning'); + $key, $this->getEvidence()), 'warning'); } else { if (!is_array($value)) { $this->addStatusMessage(sprintf('subevidence %s in evidence %s must bee an array', - $key, $this->getEvidence()), 'warning'); + $key, $this->getEvidence()), 'warning'); } } } @@ -254,8 +290,7 @@ public function takeData($data) * * @return array List of missing columns. Empty if all is ok */ - public function controlMandatoryColumns($data = null) - { + public function controlMandatoryColumns($data = null) { if (is_null($data)) { $data = $this->getData(); } @@ -281,8 +316,7 @@ public function controlMandatoryColumns($data = null) * * @return array List of ReadOnly columns. Empty if all is ok */ - public function controlReadOnlyColumns($data = null) - { + public function controlReadOnlyColumns($data = null) { if (is_null($data)) { $data = $this->getData(); } @@ -308,11 +342,10 @@ public function controlReadOnlyColumns($data = null) * * @return string FlexiBee Date or NULL */ - public static function timestampToFlexiDate($timpestamp = null) - { + public static function timestampToFlexiDate($timpestamp = null) { $flexiDate = null; if (!is_null($timpestamp)) { - $date = new \DateTime(); + $date = new \DateTime(); $date->setTimestamp($timpestamp); $flexiDate = $date->format('Y-m-d'); } @@ -326,11 +359,10 @@ public static function timestampToFlexiDate($timpestamp = null) * * @return string FlexiBee DateTime or NULL */ - public static function timestampToFlexiDateTime($timpestamp = null) - { + public static function timestampToFlexiDateTime($timpestamp = null) { $flexiDateTime = null; if (!is_null($timpestamp)) { - $date = new \DateTime(); + $date = new \DateTime(); $date->setTimestamp($timpestamp); $flexiDateTime = $date->format('Y-m-dTH:i:s'); } @@ -352,17 +384,16 @@ public static function timestampToFlexiDateTime($timpestamp = null) * @return boolean Operation success */ public function addArrayToBranch($data, $relationPath = 'polozkyDokladu', - $removeAll = false) - { + $removeAll = false) { $currentBranchData = $this->getDataValue($relationPath); - $branchData = $currentBranchData; - $branchData[] = $data; + $branchData = $currentBranchData; + $branchData[] = $data; if (is_array($this->getEvidence()) && array_key_exists('bezPolozek', - $this->getColumnsInfo())) { + $this->getColumnsInfo())) { $this->setDataValue('bezPolozek', false); } if ($removeAll === true) { - $this->setDataValue($relationPath.'@removeAll', true); + $this->setDataValue($relationPath . '@removeAll', true); } return $this->setDataValue($relationPath, $branchData); } @@ -373,10 +404,9 @@ public function addArrayToBranch($data, $relationPath = 'polozkyDokladu', * @param FlexiBeeRO $object objekt evidence * @param boolean $removeAll flush older items */ - public function addObjectToBranch($object, $removeAll = false) - { + public function addObjectToBranch($object, $removeAll = false) { $this->addArrayToBranch([$object->getEvidence() => $object->getData()], - 'polozkyDokladu', $removeAll); + 'polozkyDokladu', $removeAll); } /** @@ -385,10 +415,9 @@ public function addObjectToBranch($object, $removeAll = false) * @see https://www.flexibee.eu/api/dokumentace/ref/uzivatelske-vazby/ * @param string $vazba */ - public function vazbaAdd($vazba) - { + public function vazbaAdd($vazba) { $this->addArrayToBranch(['uzivatelska-vazba' => $vazba], - 'uzivatelske-vazby'); + 'uzivatelske-vazby'); } /** @@ -397,11 +426,10 @@ public function vazbaAdd($vazba) * @see https://www.flexibee.eu/api/dokumentace/ref/uzivatelske-vazby/ * @param string $vazba */ - public function vazbaDel($vazba) - { + public function vazbaDel($vazba) { $this->setDataValue('uzivatelska-vazba@action', 'delete'); $this->addArrayToBranch(['uzivatelska-vazba' => $vazba], - 'uzivatelske-vazby'); + 'uzivatelske-vazby'); } /** @@ -415,8 +443,7 @@ public function vazbaDel($vazba) * * @return string */ - public function getJsonizedData($data = null, $options = 0) - { + public function getJsonizedData($data = null, $options = 0) { if (is_null($data)) { $data = $this->getData(); } @@ -437,8 +464,7 @@ public function getJsonizedData($data = null, $options = 0) * * @return array */ - public function getDataForJSON($data = null) - { + public function getDataForJSON($data = null) { if (is_null($data)) { $data = $this->getData(); } @@ -460,8 +486,7 @@ public function getDataForJSON($data = null) * * @return boolean Operation success */ - public function sync($data = null) - { + public function sync($data = null) { $this->insertToFlexiBee($data); $insertResult = $this->lastResponseCode; if ($insertResult == 201) { @@ -481,8 +506,7 @@ public function sync($data = null) * * @return FlexiBeeRW|null copied record object or null in case of failure */ - public function copy($source, $overrides = []) - { + public function copy($source, $overrides = []) { $this->sourceId = $source; return $this->sync($overrides) ? $this : null; } @@ -497,20 +521,19 @@ public function copy($source, $overrides = []) * * @return boolean operation success */ - public function performAction($action, $method = 'int') - { + public function performAction($action, $method = 'int') { $actionsAvailble = $this->getActionsInfo(); if (is_array($actionsAvailble) && array_key_exists($action, - $actionsAvailble)) { + $actionsAvailble)) { switch ($actionsAvailble[$action]['actionMakesSense']) { case 'ONLY_WITH_INSTANCE_AND_NOT_IN_EDIT': case 'ONLY_WITH_INSTANCE': //Add instance - $urlSuffix = '/'.$this->__toString().'/'.$action; + $urlSuffix = '/' . $this->__toString() . '/' . $action; break; default: - $urlSuffix = '/'.$action; + $urlSuffix = '/' . $action; break; } @@ -524,12 +547,12 @@ public function performAction($action, $method = 'int') default: $result = $this->performRequest($this->evidenceUrlWithSuffix($urlSuffix), - 'GET'); + 'GET'); break; } } else { throw new \Exception(sprintf(_('Unsupported action %s for evidence %s'), - $action, $this->getEvidence())); + $action, $this->getEvidence())); } return $result; @@ -542,10 +565,9 @@ public function performAction($action, $method = 'int') * * @return array Insert result */ - public function addExternalID($extId) - { - return $this->insertToFlexiBee(['id' => [$this->getRecordID(), 'ext:'.preg_replace('/^ext:/', - '', $extId)]]); + public function addExternalID($extId) { + return $this->insertToFlexiBee(['id' => [$this->getRecordID(), 'ext:' . preg_replace('/^ext:/', + '', $extId)]]); } /** @@ -557,14 +579,13 @@ public function addExternalID($extId) * * @return array operation result */ - public function changeExternalID($selector, $newValue, $forID = null) - { - $change['@removeExternalIds'] = 'ext:'.$selector.':'; - $change['id'] = [is_null($forID) ? $this->getRecordID() : $forID, - 'ext:'.$selector.':'.$newValue]; + public function changeExternalID($selector, $newValue, $forID = null) { + $change['@removeExternalIds'] = 'ext:' . $selector . ':'; + $change['id'] = [is_null($forID) ? $this->getRecordID() : $forID, + 'ext:' . $selector . ':' . $newValue]; return $this->insertToFlexiBee($change); } - + /** * Send all unsent Documents by eMail * @@ -574,7 +595,7 @@ public function changeExternalID($selector, $newValue, $forID = null) */ public function sendUnsent() { $this->performRequest('automaticky-odeslat-neodeslane', 'PUT', 'xml'); - return $this->lastResponseCode == 202; + return $this->lastResponseCode == 202; } - + } diff --git a/testing/FlexiPeeHP/FlexiBeeROTest.php b/testing/FlexiPeeHP/FlexiBeeROTest.php new file mode 100644 index 00000000..e12a8f53 --- /dev/null +++ b/testing/FlexiPeeHP/FlexiBeeROTest.php @@ -0,0 +1,1083 @@ +object = new FlexiBeeRO(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown(): void { + + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setObjectName + * @todo Implement testSetObjectName(). + */ + public function testSetObjectName() { + $this->assertEquals('', $this->object->SetObjectName()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setUp + * @todo Implement testSetUp(). + */ + public function testSetUp() { + $this->assertEquals('', $this->object->SetUp()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::companyUrlToOptions + * @todo Implement testCompanyUrlToOptions(). + */ + public function testCompanyUrlToOptions() { + $this->assertEquals('', $this->object->CompanyUrlToOptions()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getConnectionOptions + * @todo Implement testGetConnectionOptions(). + */ + public function testGetConnectionOptions() { + $this->assertEquals('', $this->object->GetConnectionOptions()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::configToEnv + * @todo Implement testConfigToEnv(). + */ + public function testConfigToEnv() { + $this->assertEquals('', $this->object->ConfigToEnv()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::curlInit + * @todo Implement testCurlInit(). + */ + public function testCurlInit() { + $this->assertEquals('', $this->object->CurlInit()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::processInit + * @todo Implement testProcessInit(). + */ + public function testProcessInit() { + $this->assertEquals('', $this->object->ProcessInit()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setDataValue + * @todo Implement testSetDataValue(). + */ + public function testSetDataValue() { + $this->assertEquals('', $this->object->SetDataValue()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::dateToFlexiDate + * @todo Implement testDateToFlexiDate(). + */ + public function testDateToFlexiDate() { + $this->assertEquals('', $this->object->DateToFlexiDate()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::dateToFlexiDateTime + * @todo Implement testDateToFlexiDateTime(). + */ + public function testDateToFlexiDateTime() { + $this->assertEquals('', $this->object->DateToFlexiDateTime()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setPrefix + * @todo Implement testSetPrefix(). + */ + public function testSetPrefix() { + $this->assertEquals('', $this->object->SetPrefix()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setFormat + * @todo Implement testSetFormat(). + */ + public function testSetFormat() { + $this->assertEquals('', $this->object->SetFormat()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setEvidence + * @todo Implement testSetEvidence(). + */ + public function testSetEvidence() { + $this->assertEquals('', $this->object->SetEvidence()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getEvidence + * @todo Implement testGetEvidence(). + */ + public function testGetEvidence() { + $this->assertEquals('', $this->object->GetEvidence()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setCompany + * @todo Implement testSetCompany(). + */ + public function testSetCompany() { + $this->assertEquals('', $this->object->SetCompany()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getCompany + * @todo Implement testGetCompany(). + */ + public function testGetCompany() { + $this->assertEquals('', $this->object->GetCompany()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getResponseEvidence + * @todo Implement testGetResponseEvidence(). + */ + public function testGetResponseEvidence() { + $this->assertEquals('', $this->object->GetResponseEvidence()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::object2array + * @todo Implement testObject2array(). + */ + public function testObject2array() { + $this->assertEquals('', $this->object->Object2array()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::objectToID + * @todo Implement testObjectToID(). + */ + public function testObjectToID() { + $this->assertEquals('', $this->object->ObjectToID()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceURL + * @todo Implement testGetEvidenceURL(). + */ + public function testGetEvidenceURL() { + $this->assertEquals('', $this->object->GetEvidenceURL()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::evidenceUrlWithSuffix + * @todo Implement testEvidenceUrlWithSuffix(). + */ + public function testEvidenceUrlWithSuffix() { + $this->assertEquals('', $this->object->EvidenceUrlWithSuffix()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::updateApiURL + * @todo Implement testUpdateApiURL(). + */ + public function testUpdateApiURL() { + $this->assertEquals('', $this->object->UpdateApiURL()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::addDefaultUrlParams + * @todo Implement testAddDefaultUrlParams(). + */ + public function testAddDefaultUrlParams() { + $this->assertEquals('', $this->object->AddDefaultUrlParams()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::performRequest + * @todo Implement testPerformRequest(). + */ + public function testPerformRequest() { + $this->assertEquals('', $this->object->PerformRequest()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::rawResponseToArray + * @todo Implement testRawResponseToArray(). + */ + public function testRawResponseToArray() { + $this->assertEquals('', $this->object->RawResponseToArray()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::rawJsonToArray + * @todo Implement testRawJsonToArray(). + */ + public function testRawJsonToArray() { + $this->assertEquals('', $this->object->RawJsonToArray()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::rawXmlToArray + * @todo Implement testRawXmlToArray(). + */ + public function testRawXmlToArray() { + $this->assertEquals('', $this->object->RawXmlToArray()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::parseResponse + * @todo Implement testParseResponse(). + */ + public function testParseResponse() { + $this->assertEquals('', $this->object->ParseResponse()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::parseError + * @todo Implement testParseError(). + */ + public function testParseError() { + $this->assertEquals('', $this->object->ParseError()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::doCurlRequest + * @todo Implement testDoCurlRequest(). + */ + public function testDoCurlRequest() { + $this->assertEquals('', $this->object->DoCurlRequest()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::contentTypeToResponseFormat + * @todo Implement testContentTypeToResponseFormat(). + */ + public function testContentTypeToResponseFormat() { + $this->assertEquals('', $this->object->ContentTypeToResponseFormat()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setAction + * @todo Implement testSetAction(). + */ + public function testSetAction() { + $this->assertEquals('', $this->object->SetAction()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::xml2array + * @todo Implement testXml2array(). + */ + public function testXml2array() { + $this->assertEquals('', $this->object->Xml2array()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::disconnect + * @todo Implement testDisconnect(). + */ + public function testDisconnect() { + $this->assertEquals('', $this->object->Disconnect()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::__destruct + * @todo Implement test__destruct(). + */ + public function test__destruct() { + $this->assertEquals('', $this->object->__destruct()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getFlexiRow + * @todo Implement testGetFlexiRow(). + */ + public function testGetFlexiRow() { + $this->assertEquals('', $this->object->GetFlexiRow()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::extractUrlParams + * @todo Implement testExtractUrlParams(). + */ + public function testExtractUrlParams() { + $this->assertEquals('', $this->object->ExtractUrlParams()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::urlEncode + * @todo Implement testUrlEncode(). + */ + public function testUrlEncode() { + $this->assertEquals('', $this->object->UrlEncode()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getFlexiData + * @todo Implement testGetFlexiData(). + */ + public function testGetFlexiData() { + $this->assertEquals('', $this->object->GetFlexiData()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::loadFromFlexiBee + * @todo Implement testLoadFromFlexiBee(). + */ + public function testLoadFromFlexiBee() { + $this->assertEquals('', $this->object->LoadFromFlexiBee()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::reload + * @todo Implement testReload(). + */ + public function testReload() { + $this->assertEquals('', $this->object->Reload()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setFilter + * @todo Implement testSetFilter(). + */ + public function testSetFilter() { + $this->assertEquals('', $this->object->SetFilter()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getJsonizedData + * @todo Implement testGetJsonizedData(). + */ + public function testGetJsonizedData() { + $this->assertEquals('', $this->object->GetJsonizedData()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getDataForJSON + * @todo Implement testGetDataForJSON(). + */ + public function testGetDataForJSON() { + $this->assertEquals('', $this->object->GetDataForJSON()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::join + * @todo Implement testJoin(). + */ + public function testJoin() { + $this->assertEquals('', $this->object->Join()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::urlizeId + * @todo Implement testUrlizeId(). + */ + public function testUrlizeId() { + $this->assertEquals('', $this->object->UrlizeId()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::idExists + * @todo Implement testIdExists(). + */ + public function testIdExists() { + $this->assertEquals('', $this->object->IdExists()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::recordExists + * @todo Implement testRecordExists(). + */ + public function testRecordExists() { + $this->assertEquals('', $this->object->RecordExists()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getAllFromFlexibee + * @todo Implement testGetAllFromFlexibee(). + */ + public function testGetAllFromFlexibee() { + $this->assertEquals('', $this->object->GetAllFromFlexibee()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getColumnsFromFlexibee + * @todo Implement testGetColumnsFromFlexibee(). + */ + public function testGetColumnsFromFlexibee() { + $this->assertEquals('', $this->object->GetColumnsFromFlexibee()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getKod + * @todo Implement testGetKod(). + */ + public function testGetKod() { + $this->assertEquals('', $this->object->GetKod()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::logResult + * @todo Implement testLogResult(). + */ + public function testLogResult() { + $this->assertEquals('', $this->object->LogResult()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::saveDebugFiles + * @todo Implement testSaveDebugFiles(). + */ + public function testSaveDebugFiles() { + $this->assertEquals('', $this->object->SaveDebugFiles()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setPostFields + * @todo Implement testSetPostFields(). + */ + public function testSetPostFields() { + $this->assertEquals('', $this->object->SetPostFields()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getPostFields + * @todo Implement testGetPostFields(). + */ + public function testGetPostFields() { + $this->assertEquals('', $this->object->GetPostFields()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::flexiUrl + * @todo Implement testFlexiUrl(). + */ + public function testFlexiUrl() { + $this->assertEquals('', $this->object->FlexiUrl()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getRecordID + * @todo Implement testGetRecordID(). + */ + public function testGetRecordID() { + $this->assertEquals('', $this->object->GetRecordID()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getRecordCode + * @todo Implement testGetRecordCode(). + */ + public function testGetRecordCode() { + $this->assertEquals('', $this->object->GetRecordCode()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getRecordIdent + * @todo Implement testGetRecordIdent(). + */ + public function testGetRecordIdent() { + $this->assertEquals('', $this->object->GetRecordIdent()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::__toString + * @todo Implement test__toString(). + */ + public function test__toString() { + $this->assertEquals('', $this->object->__toString()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::evidenceToClassName + * @todo Implement testEvidenceToClassName(). + */ + public function testEvidenceToClassName() { + $this->assertEquals('', $this->object->EvidenceToClassName()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getFirstRecordID + * @todo Implement testGetFirstRecordID(). + */ + public function testGetFirstRecordID() { + $this->assertEquals('', $this->object->GetFirstRecordID()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getNextRecordID + * @todo Implement testGetNextRecordID(). + */ + public function testGetNextRecordID() { + $this->assertEquals('', $this->object->GetNextRecordID()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getPrevRecordID + * @todo Implement testGetPrevRecordID(). + */ + public function testGetPrevRecordID() { + $this->assertEquals('', $this->object->GetPrevRecordID()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getExternalID + * @todo Implement testGetExternalID(). + */ + public function testGetExternalID() { + $this->assertEquals('', $this->object->GetExternalID()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getExternalIDs + * @todo Implement testGetExternalIDs(). + */ + public function testGetExternalIDs() { + $this->assertEquals('', $this->object->GetExternalIDs()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getGlobalVersion + * @todo Implement testGetGlobalVersion(). + */ + public function testGetGlobalVersion() { + $this->assertEquals('', $this->object->GetGlobalVersion()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getApiURL + * @todo Implement testGetApiURL(). + */ + public function testGetApiURL() { + $this->assertEquals('', $this->object->GetApiURL()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getResponseFormat + * @todo Implement testGetResponseFormat(). + */ + public function testGetResponseFormat() { + $this->assertEquals('', $this->object->GetResponseFormat()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::unifyResponseFormat + * @todo Implement testUnifyResponseFormat(). + */ + public function testUnifyResponseFormat() { + $this->assertEquals('', $this->object->UnifyResponseFormat()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getOfflineColumnsInfo + * @todo Implement testGetOfflineColumnsInfo(). + */ + public function testGetOfflineColumnsInfo() { + $this->assertEquals('', $this->object->GetOfflineColumnsInfo()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getOnlineColumnsInfo + * @todo Implement testGetOnlineColumnsInfo(). + */ + public function testGetOnlineColumnsInfo() { + $this->assertEquals('', $this->object->GetOnlineColumnsInfo()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::updateColumnsInfo + * @todo Implement testUpdateColumnsInfo(). + */ + public function testUpdateColumnsInfo() { + $this->assertEquals('', $this->object->UpdateColumnsInfo()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getColumnsInfo + * @todo Implement testGetColumnsInfo(). + */ + public function testGetColumnsInfo() { + $this->assertEquals('', $this->object->GetColumnsInfo()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getColumnInfo + * @todo Implement testGetColumnInfo(). + */ + public function testGetColumnInfo() { + $this->assertEquals('', $this->object->GetColumnInfo()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getActionsInfo + * @todo Implement testGetActionsInfo(). + */ + public function testGetActionsInfo() { + $this->assertEquals('', $this->object->GetActionsInfo()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getRelationsInfo + * @todo Implement testGetRelationsInfo(). + */ + public function testGetRelationsInfo() { + $this->assertEquals('', $this->object->GetRelationsInfo()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceInfo + * @todo Implement testGetEvidenceInfo(). + */ + public function testGetEvidenceInfo() { + $this->assertEquals('', $this->object->GetEvidenceInfo()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceName + * @todo Implement testGetEvidenceName(). + */ + public function testGetEvidenceName() { + $this->assertEquals('', $this->object->GetEvidenceName()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::saveResponseToFile + * @todo Implement testSaveResponseToFile(). + */ + public function testSaveResponseToFile() { + $this->assertEquals('', $this->object->SaveResponseToFile()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getVazby + * @todo Implement testGetVazby(). + */ + public function testGetVazby() { + $this->assertEquals('', $this->object->GetVazby()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getFlexiBeeURL + * @todo Implement testGetFlexiBeeURL(). + */ + public function testGetFlexiBeeURL() { + $this->assertEquals('', $this->object->GetFlexiBeeURL()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setMyKey + * @todo Implement testSetMyKey(). + */ + public function testSetMyKey() { + $this->assertEquals('', $this->object->SetMyKey()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::ignore404 + * @todo Implement testIgnore404(). + */ + public function testIgnore404() { + $this->assertEquals('', $this->object->Ignore404()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::sendByMail + * @todo Implement testSendByMail(). + */ + public function testSendByMail() { + $this->assertEquals('', $this->object->SendByMail()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::flexiDateToDateTime + * @todo Implement testFlexiDateToDateTime(). + */ + public function testFlexiDateToDateTime() { + $this->assertEquals('', $this->object->FlexiDateToDateTime()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::flexiDateTimeToDateTime + * @todo Implement testFlexiDateTimeToDateTime(). + */ + public function testFlexiDateTimeToDateTime() { + $this->assertEquals('', $this->object->FlexiDateTimeToDateTime()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getInFormat + * @todo Implement testGetInFormat(). + */ + public function testGetInFormat() { + $this->assertEquals('', $this->object->GetInFormat()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::downloadInFormat + * @todo Implement testDownloadInFormat(). + */ + public function testDownloadInFormat() { + $this->assertEquals('', $this->object->DownloadInFormat()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::takeData + * @todo Implement testTakeData(). + */ + public function testTakeData() { + $this->assertEquals('', $this->object->TakeData()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getReportsInfo + * @todo Implement testGetReportsInfo(). + */ + public function testGetReportsInfo() { + $this->assertEquals('', $this->object->GetReportsInfo()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::requestAuthSessionID + * @todo Implement testRequestAuthSessionID(). + */ + public function testRequestAuthSessionID() { + $this->assertEquals('', $this->object->RequestAuthSessionID()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::login + * @todo Implement testLogin(). + */ + public function testLogin() { + $this->assertEquals('', $this->object->Login()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::logout + * @todo Implement testLogout(). + */ + public function testLogout() { + $this->assertEquals('', $this->object->Logout()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::error500Reporter + * @todo Implement testError500Reporter(). + */ + public function testError500Reporter() { + $this->assertEquals('', $this->object->Error500Reporter()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::code + * @todo Implement testCode(). + */ + public function testCode() { + $this->assertEquals('', $this->object->Code()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::uncode + * @todo Implement testUncode(). + */ + public function testUncode() { + $this->assertEquals('', $this->object->Uncode()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::arrayCleanUP + * @todo Implement testArrayCleanUP(). + */ + public function testArrayCleanUP() { + $this->assertEquals('', $this->object->ArrayCleanUP()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::logBanner + * @todo Implement testLogBanner(). + */ + public function testLogBanner() { + $this->assertEquals('', $this->object->LogBanner()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getLastOperationType + * @todo Implement testGetLastOperationType(). + */ + public function testGetLastOperationType() { + $this->assertEquals('', $this->object->GetLastOperationType()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getErrors + * @todo Implement testGetErrors(). + */ + public function testGetErrors() { + $this->assertEquals('', $this->object->GetErrors()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::__wakeup + * @todo Implement test__wakeup(). + */ + public function test__wakeup() { + $this->assertEquals('', $this->object->__wakeup()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getMyKey + * @todo Implement testGetMyKey(). + */ + public function testGetMyKey() { + $this->assertEquals('', $this->object->GetMyKey()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::getKeyColumn + * @todo Implement testGetKeyColumn(). + */ + public function testGetKeyColumn() { + $this->assertEquals('', $this->object->GetKeyColumn()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::setkeyColumn + * @todo Implement testSetkeyColumn(). + */ + public function testSetkeyColumn() { + $this->assertEquals('', $this->object->SetkeyColumn()); + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + +} diff --git a/testing/src/FlexiPeeHP/FlexiBeeROTest.php b/testing/src/FlexiPeeHP/FlexiBeeROTest.php index c1963438..908784ad 100644 --- a/testing/src/FlexiPeeHP/FlexiBeeROTest.php +++ b/testing/src/FlexiPeeHP/FlexiBeeROTest.php @@ -7,8 +7,8 @@ /** * Generated by PHPUnit_SkeletonGenerator on 2016-05-04 at 10:08:36. */ -class FlexiBeeROTest extends \Test\Ease\SandTest -{ +class FlexiBeeROTest extends \Test\Ease\SandTest { + /** * @var FlexiBeeRO */ @@ -46,11 +46,10 @@ class FlexiBeeROTest extends \Test\Ease\SandTest * This method is called before a test is executed. * @covers FlexiPeeHP\FlexiBeeRO::__construct */ - protected function setUp(): void - { - $this->object = new FlexiBeeRO(); - $this->object->prefix = '/'; - $this->object->debug = true; + protected function setUp(): void { + $this->object = new FlexiBeeRO(); + $this->object->prefix = '/'; + $this->object->debug = true; $this->object->reportRecipient = 'testreports@vitexsoftware.cz'; } @@ -58,16 +57,14 @@ protected function setUp(): void * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ - protected function tearDown(): void - { + protected function tearDown(): void { } /** * @covers FlexiPeeHP\FlexiBeeRO::logBanner */ - public function testLogBanner() - { + public function testLogBanner() { $this->object->logBanner(addslashes(get_class($this))); } @@ -77,15 +74,14 @@ public function testLogBanner() * @depends testLogBanner * @covers FlexiPeeHP\FlexiBeeRO::__construct */ - public function testConstructor() - { + public function testConstructor() { $classname = get_class($this->object); - $evidence = $this->object->getEvidence(); + $evidence = $this->object->getEvidence(); // Get mock, without the constructor being called $mock = $this->getMockBuilder($classname) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); + ->disableOriginalConstructor() + ->getMockForAbstractClass(); $mock->__construct(1, ['debug' => false]); if (!isset(\FlexiPeeHP\EvidenceList::$name[$evidence])) { @@ -93,21 +89,20 @@ public function testConstructor() } $mock->__construct('', - [ - 'company' => constant('FLEXIBEE_COMPANY'), - 'url' => constant('FLEXIBEE_URL'), - 'user' => constant('FLEXIBEE_LOGIN'), - 'password' => constant('FLEXIBEE_PASSWORD'), - 'debug' => true, - 'prefix' => 'c', - 'evidence' => $evidence]); + [ + 'company' => constant('FLEXIBEE_COMPANY'), + 'url' => constant('FLEXIBEE_URL'), + 'user' => constant('FLEXIBEE_LOGIN'), + 'password' => constant('FLEXIBEE_PASSWORD'), + 'debug' => true, + 'prefix' => 'c', + 'evidence' => $evidence]); } /** * @covers FlexiPeeHP\FlexiBeeRO::curlInit */ - public function testCurlInit() - { + public function testCurlInit() { $this->object->timeout = 120; $this->object->curlInit(); $this->assertTrue(is_resource($this->object->curl)); @@ -116,8 +111,7 @@ public function testCurlInit() /** * @covers FlexiPeeHP\FlexiBeeRO::processInit */ - public function testProcessInit() - { + public function testProcessInit() { $this->object->processInit(1); $this->object->processInit(['id' => 1]); $this->assertEquals(1, $this->object->getDataValue('id')); @@ -126,7 +120,7 @@ public function testProcessInit() $firstID = $this->object->getColumnsFromFlexibee(['id', 'kod'], - ['limit' => 1]); + ['limit' => 1]); if (count($firstID) && isset($firstID[0]['id'])) { @@ -134,14 +128,14 @@ public function testProcessInit() $this->assertNotEmpty($this->object->__toString()); if (isset($firstID[0]['kod'])) { - $this->object->processInit('code:'.$firstID[0]['kod']); + $this->object->processInit('code:' . $firstID[0]['kod']); $this->assertNotEmpty($this->object->__toString()); } - $this->object->processInit($this->object->getEvidenceURL().'/'.$firstID[0]['id'].'.xml'); + $this->object->processInit($this->object->getEvidenceURL() . '/' . $firstID[0]['id'] . '.xml'); } else { $this->markTestSkipped(sprintf('Evidence %s does not contain first record', - $this->object->getEvidence())); + $this->object->getEvidence())); } } } @@ -149,24 +143,23 @@ public function testProcessInit() /** * @covers FlexiPeeHP\FlexiBeeRO::setUp */ - public function testSetUp() - { + public function testSetUp() { $this->object->authSessionId = 'XXXtestXXX'; $this->object->setUp( - [ - 'company' => 'cmp', - 'url' => 'url', - 'user' => 'usr', - 'password' => 'pwd', - 'prefix' => 'c', - 'debug' => true, - 'defaultUrlParams' => ['limit' => 10], - 'evidence' => 'smlouva', - 'detail' => 'summary', - 'filter' => 'testfilter', - 'ignore404' => true, - 'offline' => true - ] + [ + 'company' => 'cmp', + 'url' => 'url', + 'user' => 'usr', + 'password' => 'pwd', + 'prefix' => 'c', + 'debug' => true, + 'defaultUrlParams' => ['limit' => 10], + 'evidence' => 'smlouva', + 'detail' => 'summary', + 'filter' => 'testfilter', + 'ignore404' => true, + 'offline' => true + ] ); $this->assertEquals('cmp', $this->object->company); $this->assertEquals('url', $this->object->url); @@ -178,11 +171,10 @@ public function testSetUp() /** * @covers FlexiPeeHP\FlexiBeeRO::getConnectionOptions */ - public function testGetConnectionOptions() - { - $options = $this->object->getConnectionOptions(); + public function testGetConnectionOptions() { + $options = $this->object->getConnectionOptions(); $this->assertArrayHasKey('url', $options); - $this->object->timeout = 120; + $this->object->timeout = 120; $this->object->authSessionId = 'sessid'; $this->object->setCompany('test'); $this->object->getConnectionOptions(); @@ -192,8 +184,7 @@ public function testGetConnectionOptions() * @covers FlexiPeeHP\FlexiBeeRO::setPrefix * @expectedException \Exception */ - public function testSetPrefix() - { + public function testSetPrefix() { $this->object->setPrefix('c'); $this->assertEquals('/c/', $this->object->prefix); $this->object->setPrefix(null); @@ -204,8 +195,7 @@ public function testSetPrefix() /** * @covers FlexiPeeHP\FlexiBeeRO::setFormat */ - public function testSetFormat() - { + public function testSetFormat() { $this->object->setFormat('xml'); $this->assertEquals('xml', $this->object->format); } @@ -216,8 +206,7 @@ public function testSetFormat() * @covers FlexiPeeHP\FlexiBeeRO::setEvidence * @expectedException \Exception */ - public function testSetEvidence() - { + public function testSetEvidence() { $this->object->setEvidence('adresar'); $this->assertEquals('adresar', $this->object->evidence); $this->object->setPrefix('c'); @@ -228,8 +217,7 @@ public function testSetEvidence() /** * @covers FlexiPeeHP\FlexiBeeRO::setCompany */ - public function testSetCompany() - { + public function testSetCompany() { $this->object->setCompany('test_s_r_o_'); $this->assertEquals('test_s_r_o_', $this->object->company); } @@ -237,25 +225,23 @@ public function testSetCompany() /** * @covers FlexiPeeHP\FlexiBeeRO::object2array */ - public function testObject2array() - { + public function testObject2array() { $this->assertNull($this->object->object2array(new \stdClass())); $this->assertEquals( - [ - 'item' => 1, - 'arrItem' => ['a', 'b' => 'c'] - ] - , $this->object->object2array(new \Test\ObjectForTesting())); + [ + 'item' => 1, + 'arrItem' => ['a', 'b' => 'c'] + ] + , $this->object->object2array(new \Test\ObjectForTesting())); } /** * @covers FlexiPeeHP\FlexiBeeRO::objectToID */ - public function testObjectToID() - { + public function testObjectToID() { $this->object->setDataValue('kod', 'TEST'); $this->assertEquals('code:TEST', - $this->object->objectToID($this->object)); + $this->object->objectToID($this->object)); $this->assertEquals('TEST', $this->object->objectToID('TEST')); } @@ -263,8 +249,7 @@ public function testObjectToID() /** * @covers FlexiPeeHP\FlexiBeeRO::performRequest */ - public function testPerformRequest() - { + public function testPerformRequest() { $evidence = $this->object->getEvidence(); switch ($evidence) { case null: @@ -284,38 +269,30 @@ public function testPerformRequest() //404 Test - $notFound = $this->object->performRequest('error404.json'); - if (array_key_exists('message', $notFound)) { - $this->assertEquals('false', $notFound['success']); - } else { - echo ''; - } + $this->assertNull($this->object->performRequest('error404.json')); } /** * @covers FlexiPeeHP\FlexiBeeRO::rawResponseToArray */ - public function testRawResponseToArray() - { + public function testRawResponseToArray() { $this->assertTrue(is_array( - $this->object->rawResponseToArray($this->json, 'json'))); + $this->object->rawResponseToArray($this->json, 'json'))); $this->assertTrue(is_array( - $this->object->rawResponseToArray($this->xml, 'xml'))); + $this->object->rawResponseToArray($this->xml, 'xml'))); $this->assertTrue(is_array( - $this->object->rawResponseToArray('simpletext', 'txt'))); + $this->object->rawResponseToArray('simpletext', 'txt'))); $this->assertTrue(is_array( - $this->object->rawResponseToArray('othertext', 'other'))); + $this->object->rawResponseToArray('othertext', 'other'))); } /** * @covers FlexiPeeHP\FlexiBeeRO::rawJsonToArray */ - public function testRawJsonToArray() - { - $this->assertNull($this->object->rawJsonToArray($this->json.'XXX')); - $evidence = $this->object->getResponseEvidence() ? $this->object->getResponseEvidence() - : 'adresar'; + public function testRawJsonToArray() { + $this->assertNull($this->object->rawJsonToArray($this->json . 'XXX')); + $evidence = $this->object->getResponseEvidence() ? $this->object->getResponseEvidence() : 'adresar'; $arrayWeWant = [ '@version' => '1.0', $evidence => @@ -330,16 +307,14 @@ public function testRawJsonToArray() ] ]; $this->assertEquals($arrayWeWant, - $this->object->rawJsonToArray($this->json)); + $this->object->rawJsonToArray($this->json)); } /** * @covers FlexiPeeHP\FlexiBeeRO::rawXmlToArray */ - public function testRawXmlToArray() - { - $evidence = $this->object->getResponseEvidence() ? $this->object->getResponseEvidence() - : 'adresar'; + public function testRawXmlToArray() { + $evidence = $this->object->getResponseEvidence() ? $this->object->getResponseEvidence() : 'adresar'; $arrayWeWant = [ '@version' => '1.0', $evidence => @@ -357,31 +332,36 @@ public function testRawXmlToArray() ] ]; $this->assertEquals($arrayWeWant, - $this->object->rawXmlToArray($this->xml)); + $this->object->rawXmlToArray($this->xml)); } /** * @covers FlexiPeeHP\FlexiBeeRO::parseResponse */ - public function testParseResponse() - { + public function testParseResponse() { $this->object->parseResponse($this->object->rawJsonToArray($this->json), - 200); + 200); + } + + /** + * @covers FlexiPeeHP\FlexiBeeRO::parseError + */ + public function testParseError() { + $this->object->doCurlRequest($this->object->evidenceUrlWithSuffix('404'), 'GET', 'json'); + $this->assertEquals(1, $this->object->parseError($this->object->rawJsonToArray($this->object->lastCurlResponse))); } /** * @covers FlexiPeeHP\FlexiBeeRO::doCurlRequest */ - public function testDoCurlRequest() - { + public function testDoCurlRequest() { $this->object->doCurlRequest(constant('FLEXIBEE_URL'), 'GET'); } /** * @covers FlexiPeeHP\FlexiBeeRO::setAction */ - public function testSetAction() - { + public function testSetAction() { switch ($this->object->getEvidence()) { case '': case 'c': @@ -405,25 +385,22 @@ public function testSetAction() /** * @covers FlexiPeeHP\FlexiBeeRO::getEvidence */ - public function testGetEvidence() - { + public function testGetEvidence() { $this->assertEquals($this->object->evidence, - $this->object->getEvidence()); + $this->object->getEvidence()); } /** * @covers FlexiPeeHP\FlexiBeeRO::getCompany */ - public function testGetCompany() - { + public function testGetCompany() { $this->assertEquals($this->object->company, $this->object->getCompany()); } /** * @covers FlexiPeeHP\FlexiBeeRO::getResponseEvidence */ - public function testGetResponseEvidence() - { + public function testGetResponseEvidence() { $responseEvidence = $this->object->getResponseEvidence(); switch ($this->object->getEvidence()) { case '': @@ -436,7 +413,7 @@ public function testGetResponseEvidence() break; default: $this->assertEquals($this->object->getEvidence(), - $responseEvidence); + $responseEvidence); break; } } @@ -445,16 +422,14 @@ public function testGetResponseEvidence() * @covers FlexiPeeHP\FlexiBeeRO::getLastInsertedId * @depends testInsertToFlexiBee */ - public function testGetLastInsertedId() - { + public function testGetLastInsertedId() { $this->assertNotEmpty($this->object->getLastInsertedId()); } /** * @covers FlexiPeeHP\FlexiBeeRO::xml2array */ - public function testXml2array() - { + public function testXml2array() { $arrayWeWant = [ '@version' => '1.0', 'adresar' => @@ -478,8 +453,7 @@ public function testXml2array() /** * @covers FlexiPeeHP\FlexiBeeRO::extractUrlParams */ - public function testExtractUrlParams() - { + public function testExtractUrlParams() { $conditions = ['id' => 23, 'limit' => 10]; $this->object->extractUrlParams($conditions, $urlParams); $this->assertEquals(['id' => 23], $conditions); @@ -489,17 +463,15 @@ public function testExtractUrlParams() /** * @covers FlexiPeeHP\FlexiBeeRO::urlEncode */ - public function testUrlEncode() - { + public function testUrlEncode() { $this->assertEquals("stitky%3D'code:VIP'%20or%20stitky%3D'code:DULEZITE'", - FlexiBeeRO::urlEncode("stitky='code:VIP' or stitky='code:DULEZITE'")); + FlexiBeeRO::urlEncode("stitky='code:VIP' or stitky='code:DULEZITE'")); } /** * @covers FlexiPeeHP\FlexiBeeRO::getAllFromFlexibee */ - public function testGetAllFromFlexibee() - { + public function testGetAllFromFlexibee() { $this->object->getAllFromFlexibee(); } @@ -517,8 +489,7 @@ public function testGetAllFromFlexibee() * @depends testGetColumnsFromFlexibee * @depends testSearchString */ - public function testDisconnect() - { + public function testDisconnect() { $this->object->disconnect(); $this->assertNull($this->object->curl); } @@ -527,16 +498,14 @@ public function testDisconnect() * @covers FlexiPeeHP\FlexiBeeRO::__destruct * @depends testDisconnect */ - public function testdestruct() - { + public function testdestruct() { $this->markTestSkipped(); } /** * @covers FlexiPeeHP\FlexiBeeRO::getFlexiRow */ - public function testGetFlexiRow() - { + public function testGetFlexiRow() { $this->object->getFlexiRow(0); $this->object->getFlexiRow(1); } @@ -544,30 +513,29 @@ public function testGetFlexiRow() /** * @covers FlexiPeeHP\FlexiBeeRO::getFlexiData */ - public function testGetFlexiData() - { + public function testGetFlexiData() { $evidence = $this->object->getEvidence(); switch ($evidence) { case null: $this->object->getFlexiData(); break; case 'c': - $this->object->evidence = 'c'; - $this->object->prefix = ''; - $this->object->company = ''; + $this->object->evidence = 'c'; + $this->object->prefix = ''; + $this->object->company = ''; $this->object->nameSpace = 'companies'; - $flexidata = $this->object->getFlexiData(); + $flexidata = $this->object->getFlexiData(); $this->assertArrayHasKey('company', $flexidata); break; case 'evidence-list': - $flexidata = $this->object->getFlexiData(null, - ['detail' => 'id']); + $flexidata = $this->object->getFlexiData(null, + ['detail' => 'id']); $this->assertArrayHasKey('evidenceType', $flexidata[0]); break; default: $flexidata = $this->object->getFlexiData(null, - ['detail' => 'id']); + ['detail' => 'id']); if (is_array($flexidata)) { if (count($flexidata)) { @@ -577,7 +545,7 @@ public function testGetFlexiData() $this->assertArrayHasKey('id', $flexidata[0]); $filtrered = $this->object->getFlexiData(null, - ["id = ".$flexidata[0]['id'], 'detail' => 'full']); + ["id = " . $flexidata[0]['id'], 'detail' => 'full']); $this->assertArrayHasKey(0, $filtrered); $this->assertArrayHasKey('id', $filtrered[0]); } @@ -589,8 +557,7 @@ public function testGetFlexiData() /** * @covers FlexiPeeHP\FlexiBeeRO::loadFromFlexiBee */ - public function testLoadFromFlexiBee() - { + public function testLoadFromFlexiBee() { $this->object->loadFromFlexiBee(); $this->object->loadFromFlexiBee(222); } @@ -598,10 +565,9 @@ public function testLoadFromFlexiBee() /** * @covers FlexiPeeHP\FlexiBeeRO::getJsonizedData */ - public function testGetJsonizedData() - { - $this->assertEquals('{"'.$this->object->nameSpace.'":{"@version":"1.0","'.$this->object->evidence.'":{"key":"value"}}}', - $this->object->getJsonizedData(['key' => 'value'])); + public function testGetJsonizedData() { + $this->assertEquals('{"' . $this->object->nameSpace . '":{"@version":"1.0","' . $this->object->evidence . '":{"key":"value"}}}', + $this->object->getJsonizedData(['key' => 'value'])); switch ($this->object->getEvidence()) { case '': @@ -615,8 +581,8 @@ public function testGetJsonizedData() break; default: $this->object->setAction('copy'); - $this->assertEquals('{"'.$this->object->nameSpace.'":{"@version":"1.0","'.$this->object->evidence.'":{"key":"value"},"'.$this->object->evidence.'@action":"copy"}}', - $this->object->getJsonizedData(['key' => 'value'])); + $this->assertEquals('{"' . $this->object->nameSpace . '":{"@version":"1.0","' . $this->object->evidence . '":{"key":"value"},"' . $this->object->evidence . '@action":"copy"}}', + $this->object->getJsonizedData(['key' => 'value'])); $this->object->action = 'storno'; $this->object->filter = "stavUhrK = 'stavUhr.uhrazeno'"; @@ -628,16 +594,14 @@ public function testGetJsonizedData() /** * @covers FlexiPeeHP\FlexiBeeRO::getDataForJSON */ - public function testGetDataForJson() - { + public function testGetDataForJson() { $this->object->getDataForJSON(); } /** * @covers FlexiPeeHP\FlexiBeeRO::idExists */ - public function testIdExists() - { + public function testIdExists() { $this->assertFalse($this->object->idExists('nonexistent')); switch ($this->object->getEvidence()) { case '': @@ -650,7 +614,7 @@ public function testIdExists() break; default: $first = $this->object->getColumnsFromFlexibee(['id'], - ['limit' => 1], 'id'); + ['limit' => 1], 'id'); if (empty($first)) { $this->markTestSkipped('empty evidence ?'); } else { @@ -664,8 +628,7 @@ public function testIdExists() /** * @covers FlexiPeeHP\FlexiBeeRO::getRecordID */ - public function testGetRecordID() - { + public function testGetRecordID() { $this->object->setData([$this->object->getKeyColumn() => 10]); $this->assertEquals(10, $this->object->getRecordID()); } @@ -673,8 +636,7 @@ public function testGetRecordID() /** * @covers FlexiPeeHP\FlexiBeeRO::getRecordIdent */ - public function testGetRecordIdent() - { + public function testGetRecordIdent() { $this->object->dataReset(); $this->assertNull($this->object->getRecordIdent()); @@ -691,8 +653,7 @@ public function testGetRecordIdent() /** * @covers FlexiPeeHP\FlexiBeeRO::recordExists */ - public function testRecordExists() - { + public function testRecordExists() { $evidence = $this->object->getEvidence(); switch ($evidence) { @@ -705,19 +666,19 @@ public function testRecordExists() default: $flexidata = $this->object->getFlexiData(null, - ['limit' => 1, 'detail' => 'id']); + ['limit' => 1, 'detail' => 'id']); if (is_array($flexidata) && !count($flexidata)) { $this->assertFalse($this->object->recordExists(['id' => 1]), - 'Record ID 1 exists in empty evidence ?'); + 'Record ID 1 exists in empty evidence ?'); } else { if (!is_null($flexidata)) { $this->object->setData(['id' => (int) $flexidata[0]['id']]); $this->assertTrue($this->object->recordExists(), - 'First record exists test failed'); + 'First record exists test failed'); $this->assertFalse($this->object->recordExists(['id' => 0]), - 'Record ID 0 exists'); + 'Record ID 0 exists'); $this->assertFalse($this->object->recordExists(['unexistent' => 1]), - 'Unexistent Record exist ?'); + 'Unexistent Record exist ?'); } } break; @@ -727,8 +688,7 @@ public function testRecordExists() /** * @covers FlexiPeeHP\FlexiBeeRO::getColumnsFromFlexibee */ - public function testGetColumnsFromFlexibee() - { + public function testGetColumnsFromFlexibee() { switch ($this->object->getEvidence()) { case '': @@ -741,9 +701,9 @@ public function testGetColumnsFromFlexibee() break; default: $this->object->getColumnsFromFlexibee(['id', 'kod'], - ['limit' => 1], 'id'); + ['limit' => 1], 'id'); $this->object->getColumnsFromFlexibee('summary', ['limit' => 1], - 'id'); + 'id'); break; } @@ -752,12 +712,11 @@ public function testGetColumnsFromFlexibee() /** * @covers FlexiPeeHP\FlexiBeeRO::getExternalID */ - public function testGetExternalID() - { + public function testGetExternalID() { $this->assertTrue(empty($this->object->getExternalID('ext:test:10'))); //ext: does not exist $this->object->setDataValue('external-ids', - ['ext:doe:22', 'ext:test:10']); + ['ext:doe:22', 'ext:test:10']); $this->assertEquals('ext:doe:22', $this->object->getExternalID()); $this->assertEquals('10', $this->object->getExternalID('test')); @@ -766,8 +725,7 @@ public function testGetExternalID() /** * @covers FlexiPeeHP\FlexiBeeRO::getGlobalVersion */ - public function testGetGlobalVersion() - { + public function testGetGlobalVersion() { switch ($this->object->getEvidence()) { case '': case 'c': @@ -780,8 +738,8 @@ public function testGetGlobalVersion() break; default: $this->assertInternalType("int", - $this->object->getGlobalVersion(), - 'error obtaining of GlobalVersion'); + $this->object->getGlobalVersion(), + 'error obtaining of GlobalVersion'); break; } } @@ -789,128 +747,120 @@ public function testGetGlobalVersion() /** * @covers FlexiPeeHP\FlexiBeeRO::getApiURL */ - public function testGetApiUrl() - { + public function testGetApiUrl() { $evidence = $this->object->getEvidence(); if ($evidence) { - $url = $this->object->url.'/c/'.constant('FLEXIBEE_COMPANY').'/'.$evidence; + $url = $this->object->url . '/c/' . constant('FLEXIBEE_COMPANY') . '/' . $evidence; } else { - $url = $this->object->url.'/c/'.constant('FLEXIBEE_COMPANY'); + $url = $this->object->url . '/c/' . constant('FLEXIBEE_COMPANY'); } $this->assertEquals($url, $this->object->getApiURL()); - $this->assertEquals($url.'.html', $this->object->getApiURL('html')); - $this->assertEquals($url.'.xml', $this->object->getApiURL('xml')); + $this->assertEquals($url . '.html', $this->object->getApiURL('html')); + $this->assertEquals($url . '.xml', $this->object->getApiURL('xml')); } /** * @covers FlexiPeeHP\FlexiBeeRO::getResponseFormat */ - public function testGetResponseFormat() - { + public function testGetResponseFormat() { $this->object->performRequest(null, 'GET', 'json'); - $this->assertEquals('application/json', - $this->object->getResponseFormat()); + $this->assertEquals('json', $this->object->getResponseFormat()); $this->object->performRequest(null, 'GET', 'xml'); - $this->assertEquals('application/xml', - $this->object->getResponseFormat()); - unset($this->object->curlInfo['content_type']); - $this->assertNull($this->object->getResponseFormat()); + $this->assertEquals('xml', $this->object->getResponseFormat()); +// unset($this->object->curlInfo['content_type']); +// $this->assertNull($this->object->getResponseFormat()); } /** * @covers FlexiPeeHP\FlexiBeeRO::getKod */ - public function testGetKod() - { + public function testGetKod() { $testString = []; $this->assertEquals('code:CODE', - $this->object->getKod([$this->object->keyColumn => 'code'])); + $this->object->getKod([$this->object->keyColumn => 'code'])); $testString[$this->object->nameColumn] = 'Fish clamp - Úchytka pro instalaci samonosných kabelů ' - .'(3.5 mm)'; - $code0 = $this->object->getKod($testString); + . '(3.5 mm)'; + $code0 = $this->object->getKod($testString); $this->assertEquals('code:FISHCLAMPUCHYTKAPR', $code0); - $code1 = $this->object->getKod($testString, - false); + $code1 = $this->object->getKod($testString, + false); $this->assertEquals('code:FISHCLAMPUCHYTKAPR', $code1); - $code2 = $this->object->getKod($testString); + $code2 = $this->object->getKod($testString); $this->assertEquals('code:FISHCLAMPUCHYTKAPR1', $code2); $this->object->setData($testString); - $code3 = $this->object->getKod(); + $code3 = $this->object->getKod(); $this->assertEquals('code:FISHCLAMPUCHYTKAPR2', $code3); $this->assertEquals('code:TEST', - $this->object->getKod([$this->object->nameColumn => 'test'])); + $this->object->getKod([$this->object->nameColumn => 'test'])); $this->assertEquals('code:TEST1', $this->object->getKod('test')); $this->assertEquals('code:TEST2', - $this->object->getKod(['kod' => 'test'])); + $this->object->getKod(['kod' => 'test'])); $this->assertEquals('code:NOTSET', $this->object->getKod(['kod' => ''])); } /** * @covers FlexiPeeHP\FlexiBeeRO::logResult */ - public function testLogResult() - { - $this->object->cleanMessages(); + public function testLogResult() { +// $this->object->cleanMessages(); $success = json_decode('{"winstrom":{"@version":"1.0","success":"true",' - .'"stats":{"created":"0","updated":"1","deleted":"0","skipped":"0"' - .',"failed":"0"},"results":[{"id":"1","request-id":"ext:SōkoMan.item' - .':5271","ref":"/c/spoje_net_s_r_o_1/skladovy-pohyb/1.json"}]}}'); + . '"stats":{"created":"0","updated":"1","deleted":"0","skipped":"0"' + . ',"failed":"0"},"results":[{"id":"1","request-id":"ext:SōkoMan.item' + . ':5271","ref":"/c/spoje_net_s_r_o_1/skladovy-pohyb/1.json"}]}}'); $this->object->logResult(current($this->object->object2array($success)), - 'http://test'); + 'http://test'); - $this->assertArrayHasKey('info', $this->object->getStatusMessages(true)); +// $this->assertArrayHasKey('info', $this->object->getStatusMessages(true)); - $error = json_decode('{"winstrom":{"@version":"1.0","success":"false",' - .'"stats":{"created":"0","updated":"0","deleted":"0","skipped":"0"' - .',"failed":"0"},"results":[{"errors":[{"message":"cz.winstrom.' - .'service.WSBusinessException: Zadaný kód není unikátní.\nZadaný' - .' kód není unikátní."}]}]}}'); + $error = json_decode('{"winstrom":{"@version":"1.0","success":"false",' + . '"stats":{"created":"0","updated":"0","deleted":"0","skipped":"0"' + . ',"failed":"0"},"results":[{"errors":[{"message":"cz.winstrom.' + . 'service.WSBusinessException: Zadaný kód není unikátní.\nZadaný' + . ' kód není unikátní."}]}]}}'); $this->object->lastResponseCode = 500; $this->object->logResult(current($this->object->object2array($error))); - $this->assertArrayHasKey('error', $this->object->getStatusMessages(true)); +// $this->assertArrayHasKey('error', $this->object->getStatusMessages(true)); } /** * @covers FlexiPeeHP\FlexiBeeRO::flexiUrl */ - public function testFlexiUrl() - { + public function testFlexiUrl() { $this->assertEquals("a eq '1' and b eq 'foo'", - $this->object->flexiUrl(['a' => 1, 'b' => 'foo'], 'and')); + $this->object->flexiUrl(['a' => 1, 'b' => 'foo'], 'and')); $this->assertEquals("a eq '1' or b eq 'bar'", - $this->object->flexiUrl(['a' => 1, 'b' => 'bar'], 'or')); + $this->object->flexiUrl(['a' => 1, 'b' => 'bar'], 'or')); $this->assertEquals("a eq true or b eq false", - $this->object->flexiUrl(['a' => true, 'b' => false], 'or')); + $this->object->flexiUrl(['a' => true, 'b' => false], 'or')); $this->assertEquals("a is null and b is not null", - $this->object->flexiUrl(['a' => null, 'b' => '!null'], 'and')); + $this->object->flexiUrl(['a' => null, 'b' => '!null'], 'and')); $begin = new \DateTime('2018-08-01'); - $end = new \DateTime('2018-08-31'); - $end = $end->modify('+1 day'); + $end = new \DateTime('2018-08-31'); + $end = $end->modify('+1 day'); - $interval = new \DateInterval('P1D'); + $interval = new \DateInterval('P1D'); $daterange = new \DatePeriod($begin, $interval, $end); $this->assertEquals("a eq '2018-10-25' and b between '2018-08-01' '2018-09-01'", - $this->object->flexiUrl(['a' => new \DateTime('25-10-2018'), 'b' => $daterange])); + $this->object->flexiUrl(['a' => new \DateTime('25-10-2018'), 'b' => $daterange])); } /** * @covers FlexiPeeHP\FlexiBeeRO::unifyResponseFormat */ - public function testunifyResponseFormat() - { + public function testunifyResponseFormat() { $this->assertNull($this->object->unifyResponseFormat(null)); //One Row Test $responseEvidence = $this->object->getResponseEvidence(); if (empty($responseEvidence)) { - $responseEvidence = $this->object->evidence = 'test'; + $responseEvidence = $this->object->evidence = 'test'; } $test1raw = [$responseEvidence => @@ -924,7 +874,7 @@ public function testunifyResponseFormat() ]; $this->assertEquals($test1expected, - $this->object->unifyResponseFormat($test1raw)); + $this->object->unifyResponseFormat($test1raw)); //Two Row Test $test2Raw = [$this->object->getResponseEvidence() => @@ -942,14 +892,13 @@ public function testunifyResponseFormat() ]; $this->assertEquals($test2expected, - $this->object->unifyResponseFormat($test2Raw)); + $this->object->unifyResponseFormat($test2Raw)); } /** * @covers FlexiPeeHP\FlexiBeeRO::__toString */ - public function testtoString() - { + public function testtoString() { $id = '123'; $this->object->setMyKey($id); $this->assertEquals($id, (string) $this->object); @@ -957,10 +906,11 @@ public function testtoString() $this->object->setDataValue('kod', 'test'); $this->assertEquals('code:TEST', (string) $this->object); - $identifer = 'ext:test:123'; - $this->object->setMyKey($identifer); - $this->assertEquals($identifer, (string) $this->object); - + if (!empty($this->object->evidenceInfo)) { + $identifer = 'ext:test:123'; + $this->object->setMyKey($identifer); + $this->assertEquals($identifer, (string) $this->object); + } $this->object->dataReset(); $this->assertEquals('', $this->object->__toString()); } @@ -968,8 +918,7 @@ public function testtoString() /** * @covers FlexiPeeHP\FlexiBeeRO::draw */ - public function testDraw($whatWant = NULL) - { + public function testDraw($whatWant = NULL) { $this->object->setDataValue('kod', 'test'); $this->assertEquals('code:TEST', $this->object->draw()); } @@ -977,8 +926,7 @@ public function testDraw($whatWant = NULL) /** * @covers FlexiPeeHP\FlexiBeeRO::getColumnsInfo */ - public function testgetColumnsInfo() - { + public function testgetColumnsInfo() { switch ($this->object->getEvidence()) { case '': case 'c': @@ -990,7 +938,7 @@ public function testgetColumnsInfo() break; default: $this->assertNotEmpty($this->object->getColumnsInfo(), - 'Cannot obtain structure for '.$this->object->getEvidence()); + 'Cannot obtain structure for ' . $this->object->getEvidence()); break; } } @@ -998,8 +946,7 @@ public function testgetColumnsInfo() /** * @covers FlexiPeeHP\FlexiBeeRO::getActionsInfo */ - public function testgetActionsInfo() - { + public function testgetActionsInfo() { switch ($this->object->getEvidence()) { case '': case 'c': @@ -1010,11 +957,11 @@ public function testgetActionsInfo() case 'evidence-list': $this->assertNull($this->object->getActionsInfo()); $this->assertNotEmpty($this->object->getActionsInfo('faktura-vydana'), - 'Cannot obtain actions for na evidence'); + 'Cannot obtain actions for na evidence'); break; default: $this->assertNotEmpty($this->object->getActionsInfo(), - 'Cannot obtain actions for '.$this->object->getEvidence()); + 'Cannot obtain actions for ' . $this->object->getEvidence()); break; } } @@ -1022,8 +969,7 @@ public function testgetActionsInfo() /** * @covers FlexiPeeHP\FlexiBeeRO::getRelationsInfo */ - public function testgetRelationsInfo() - { + public function testgetRelationsInfo() { switch ($this->object->getEvidence()) { case '': case 'c': @@ -1038,7 +984,7 @@ public function testgetRelationsInfo() break; default: $this->assertNotEmpty($this->object->getRelationsInfo(), - 'Cannot obtain relations for '.$this->object->getEvidence()); + 'Cannot obtain relations for ' . $this->object->getEvidence()); break; } } @@ -1046,8 +992,7 @@ public function testgetRelationsInfo() /** * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceUrl */ - public function testgetEvidenceUrl() - { + public function testgetEvidenceUrl() { $this->assertNotEmpty($this->object->getEvidenceUrl()); $this->assertNotEmpty($this->object->getEvidenceUrl('/properties')); } @@ -1055,17 +1000,15 @@ public function testgetEvidenceUrl() /** * @covers FlexiPeeHP\FlexiBeeRO::evidenceToClassName */ - public function testevidenceToClassName() - { + public function testevidenceToClassName() { $this->assertEquals('FakturaVydana', - $this->object->evidenceToClassName('faktura-vydana')); + $this->object->evidenceToClassName('faktura-vydana')); } /** * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceInfo */ - public function testGetEvidenceInfo() - { + public function testGetEvidenceInfo() { $eInfo = $this->object->getEvidenceInfo(); switch ($this->object->getEvidence()) { case '': @@ -1085,8 +1028,7 @@ public function testGetEvidenceInfo() /** * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceName */ - public function testGetEvidenceName() - { + public function testGetEvidenceName() { $evidenceName = $this->object->getEvidenceName(); switch ($this->object->getEvidence()) { case '': @@ -1106,9 +1048,8 @@ public function testGetEvidenceName() /** * @covers FlexiPeeHP\FlexiBeeRO::saveResponseToFile */ - public function testSaveResponseToFile() - { - $tmp = sys_get_temp_dir().'/'.tmpfile(); + public function testSaveResponseToFile() { + $tmp = sys_get_temp_dir() . '/' . tmpfile(); $this->object->saveResponseToFile($tmp); $this->assertFileExists($tmp); } @@ -1116,8 +1057,7 @@ public function testSaveResponseToFile() /** * @covers FlexiPeeHP\FlexiBeeRO::getFirstRecordID() */ - public function testgetFirstRecordID() - { + public function testgetFirstRecordID() { $this->object->getFirstRecordID(); switch ($this->object->getEvidence()) { case '': @@ -1137,8 +1077,7 @@ public function testgetFirstRecordID() * @covers FlexiPeeHP\FlexiBeeRO::getVazby * @expectedException \Exception */ - public function testGetVazby() - { + public function testGetVazby() { switch ($this->object->getEvidence()) { case '': case 'c': @@ -1158,23 +1097,21 @@ public function testGetVazby() /** * @covers FlexiPeeHP\FlexiBeeRO::evidenceUrlWithSuffix */ - public function testEvidenceUrlWithSuffix() - { + public function testEvidenceUrlWithSuffix() { $urlraw = $this->object->getEvidenceURL(); - $lala = $this->object->evidenceUrlWithSuffix('lala'); - $this->assertEquals($urlraw.'/lala', $lala); - $lolo = $this->object->evidenceUrlWithSuffix('?lele'); - $this->assertEquals($urlraw.'?lele', $lolo); - $lulu = $this->object->evidenceUrlWithSuffix(';lulu'); - $this->assertEquals($urlraw.';lulu', $lulu); + $lala = $this->object->evidenceUrlWithSuffix('lala'); + $this->assertEquals($urlraw . '/lala', $lala); + $lolo = $this->object->evidenceUrlWithSuffix('?lele'); + $this->assertEquals($urlraw . '?lele', $lolo); + $lulu = $this->object->evidenceUrlWithSuffix(';lulu'); + $this->assertEquals($urlraw . ';lulu', $lulu); } /** * @covers FlexiPeeHP\FlexiBeeRO::join * @expectedException \Ease\Exception */ - public function testJoin() - { + public function testJoin() { $ada = new FlexiBeeRO(['id' => 'A'], ['evidence' => 'adresar']); $adb = new FlexiBeeRO(['id' => 'B'], ['evidence' => 'adresar']); $this->assertTrue($this->object->join($ada)); @@ -1186,48 +1123,43 @@ public function testJoin() /** * @covers FlexiPeeHP\FlexiBeeRO::addDefaultUrlParams */ - public function testAddDefaultUrlParams() - { - $this->object->defaultUrlParams = []; + public function testAddDefaultUrlParams() { + $this->object->defaultUrlParams = []; $this->assertEquals('http://vitexsoftware.cz?a=b', - $this->object->addDefaultUrlParams('http://vitexsoftware.cz?a=b')); + $this->object->addDefaultUrlParams('http://vitexsoftware.cz?a=b')); $this->object->defaultUrlParams['id'] = 1; $this->assertEquals('http://vitexsoftware.cz/path?id=1&a=b', - $this->object->addDefaultUrlParams('http://vitexsoftware.cz/path?a=b')); + $this->object->addDefaultUrlParams('http://vitexsoftware.cz/path?a=b')); } - public function testFlexiDateToDateTime() - { + public function testFlexiDateToDateTime() { $this->assertEquals(1495749600, - FlexiBeeRO::flexiDateToDateTime('2017-05-26+02:00')->getTimestamp()); + FlexiBeeRO::flexiDateToDateTime('2017-05-26+02:00')->getTimestamp()); } - public function testFlexiDateTimeToDateTime() - { + public function testFlexiDateTimeToDateTime() { $this->assertEquals(1506412853, - FlexiBeeRO::flexiDateTimeToDateTime('2017-09-26T10:00:53.755+02:00')->getTimestamp()); + FlexiBeeRO::flexiDateTimeToDateTime('2017-09-26T10:00:53.755+02:00')->getTimestamp()); } /** * @covers FlexiPeeHP\FlexiBeeRO::takeData */ - public function testTakeData() - { + public function testTakeData() { $this->object->takeData(['id' => 1]); - $this->assertEquals(constant('FLEXIBEE_URL').'/'.constant('FLEXIBEE_COMPANY').'/1', - $this->object->getApiURL()); + $this->assertEquals(constant('FLEXIBEE_URL') . '/' . constant('FLEXIBEE_COMPANY') . '/1', + $this->object->getApiURL()); $this->object->dataReset(); $this->object->takeData(['kod' => 'test']); - $this->assertEquals(constant('FLEXIBEE_URL').'/'.constant('FLEXIBEE_COMPANY').'/code:TEST', - $this->object->getApiURL()); + $this->assertEquals(constant('FLEXIBEE_URL') . '/' . constant('FLEXIBEE_COMPANY') . '/code:TEST', + $this->object->getApiURL()); } /** * @covers FlexiPeeHP\FlexiBeeRO::setDataValue */ - public function testSetDataValue() - { + public function testSetDataValue() { if (!empty($this->object->getColumnsInfo())) { $this->object->setDataValue('datVyst', new \DateTime()); } @@ -1239,8 +1171,7 @@ public function testSetDataValue() /** * @covers FlexiPeeHP\FlexiBeeRO::saveDebugFiles */ - public function testSaveDebugFiles() - { + public function testSaveDebugFiles() { $this->object->saveDebugFiles(); } @@ -1248,8 +1179,7 @@ public function testSaveDebugFiles() * @covers FlexiPeeHP\FlexiBeeRO::setPostFields * @covers FlexiPeeHP\FlexiBeeRO::getPostFields */ - public function testSetPostFields() - { + public function testSetPostFields() { $this->object->setPostFields('test'); $this->assertEquals($this->object->getPostFields(), 'test'); } @@ -1259,11 +1189,10 @@ public function testSetPostFields() * * @covers FlexiPeeHP\FlexiBeeRO::dateToFlexiDate */ - public function testDateToFlexiDate() - { + public function testDateToFlexiDate() { $dater = new \DateTime(); $this->assertEquals($dater->format(FlexiBeeRO::$DateFormat), - FlexiBeeRO::dateToFlexiDate($dater)); + FlexiBeeRO::dateToFlexiDate($dater)); } /** @@ -1271,15 +1200,13 @@ public function testDateToFlexiDate() * * @covers FlexiPeeHP\FlexiBeeRO::dateToFlexiDateTime */ - public function testDateToFlexiDateTime() - { + public function testDateToFlexiDateTime() { $dater = new \DateTime(); $this->assertEquals($dater->format(FlexiBeeRO::$DateTimeFormat), - FlexiBeeRO::dateToFlexiDateTime($dater)); + FlexiBeeRO::dateToFlexiDateTime($dater)); } - public function testSetFilter() - { + public function testSetFilter() { $this->object->setFilter('X'); $this->object->setFilter(['a' => 'b']); } @@ -1287,24 +1214,21 @@ public function testSetFilter() /** * @covers FlexiPeeHP\FlexiBeeRO::getColumnInfo */ - public function testGetColumnInfo() - { + public function testGetColumnInfo() { $this->object->getColumnInfo('id'); } /** * @covers FlexiPeeHP\FlexiBeeRO::getFlexiBeeURL */ - public function testGetFlexiBeeURL() - { + public function testGetFlexiBeeURL() { $this->object->getFlexiBeeURL(); } /** * @covers FlexiPeeHP\FlexiBeeRO::error500Reporter */ - public function testError500Reporter() - { + public function testError500Reporter() { $this->object->reportRecipient = 'testreports@vitexsoftware.cz'; $this->object->error500Reporter(['success' => 'false', 'message' => 'test']); } @@ -1312,16 +1236,14 @@ public function testError500Reporter() /** * @covers FlexiPeeHP\FlexiBeeRO::setMyKey */ - public function testSetMyKey() - { + public function testSetMyKey() { $this->object->setMyKey(1); } /** * @covers FlexiPeeHP\FlexiBeeRO::ignore404 */ - public function testIgnore404() - { + public function testIgnore404() { $this->object->ignore404(true); $this->assertTrue($this->object->ignore404()); } @@ -1329,10 +1251,9 @@ public function testIgnore404() /** * @covers FlexiPeeHP\FlexiBeeRO::sendByMail */ - public function testSendByMail() - { + public function testSendByMail() { $this->object->sendByMail($this->object->reportRecipient, 'test', - 'test body'); + 'test body'); } /** @@ -1340,8 +1261,7 @@ public function testSendByMail() * @expectedExceptionMessage Unknown language ua for PDF export * @covers FlexiPeeHP\FlexiBeeRO::getInFormat */ - public function testGetInFormat() - { + public function testGetInFormat() { $this->object->evidence = 'test'; $this->object->getInFormat('html', 'test'); $this->object->getInFormat('pdf', 'test'); @@ -1352,16 +1272,14 @@ public function testGetInFormat() /** * @covers FlexiPeeHP\FlexiBeeRO::downloadInFormat */ - public function testDownloadInFormat() - { - $this->object->downloadInFormat('pdf', sys_get_temp_dir().'/'); + public function testDownloadInFormat() { + $this->object->downloadInFormat('pdf', sys_get_temp_dir() . '/'); } /** * @covers FlexiPeeHP\FlexiBeeRO::getReportsInfo */ - public function testGetReportsInfo() - { + public function testGetReportsInfo() { $result = $this->object->getReportsInfo(); switch ($this->object->getEvidence()) { case '': @@ -1373,7 +1291,7 @@ public function testGetReportsInfo() break; default: $this->assertNotEmpty($result, - 'Cannot obtain reports for '.$this->object->getEvidence()); + 'Cannot obtain reports for ' . $this->object->getEvidence()); break; } } @@ -1381,41 +1299,37 @@ public function testGetReportsInfo() /** * @covers FlexiPeeHP\FlexiBeeRO::code */ - public function testCode() - { + public function testCode() { $this->assertEquals('code:TEST', FlexiBeeRO::code('test')); } /** * @covers FlexiPeeHP\FlexiBeeRO::uncode */ - public function testUncode() - { + public function testUncode() { $this->assertEquals('test', FlexiBeeRO::uncode('code:test')); } /** * @covers FlexiPeeHP\FlexiBeeRO::arrayCleanUP */ - public function testArrayCleanUP() - { + public function testArrayCleanUP() { $this->assertEquals(['a' => 'b'], - FlexiBeeRO::arrayCleanUP(['a' => 'b', '@a' => 'aaa'])); + FlexiBeeRO::arrayCleanUP(['a' => 'b', '@a' => 'aaa'])); } /** * @covers FlexiPeeHP\FlexiBeeRO::__wakeup */ - public function test__wakeup() - { + public function test__wakeup() { $this->object->__wakeup(); } /** * @covers FlexiPeeHP\FlexiBeeRO::__destruct */ - public function test_destruct() - { + public function test_destruct() { $this->object->__destruct(); } + } diff --git a/testing/src/FlexiPeeHP/FlexiBeeRWTest.php b/testing/src/FlexiPeeHP/FlexiBeeRWTest.php index f15384a7..d04a0bc2 100644 --- a/testing/src/FlexiPeeHP/FlexiBeeRWTest.php +++ b/testing/src/FlexiPeeHP/FlexiBeeRWTest.php @@ -7,8 +7,8 @@ /** * Generated by PHPUnit_SkeletonGenerator on 2016-05-04 at 10:08:36. */ -class FlexiBeeRWTest extends FlexiBeeROTest -{ +class FlexiBeeRWTest extends FlexiBeeROTest { + /** * Poznámka vkládaná do záznamů vytvářených během testů * @var string @@ -33,27 +33,26 @@ class FlexiBeeRWTest extends FlexiBeeROTest * * @return array */ - public function getDataForInsert($code = 'UnitTest') - { + public function getDataForInsert($code = 'UnitTest') { $dataForInsert = []; - $structure = $this->object->getColumnsInfo(); + $structure = $this->object->getColumnsInfo(); if (count($structure)) { if (array_key_exists('typDokl', $structure)) { if ($structure['typDokl']['type'] == 'relation') { - $relatedEvidence = basename($structure['typDokl']['url']); - $loader = new \FlexiPeeHP\FlexiBeeRO(null, - ['evidence' => $relatedEvidence]); - $typDoklRaw = $loader->getColumnsFromFlexibee([ + $relatedEvidence = basename($structure['typDokl']['url']); + $loader = new \FlexiPeeHP\FlexiBeeRO(null, + ['evidence' => $relatedEvidence]); + $typDoklRaw = $loader->getColumnsFromFlexibee([ 'kod'], ['limit' => 1]); $dataForInsert['typDokl'] = \FlexiPeeHP\FlexiBeeRO::code($typDoklRaw[0]['kod']); } } if (array_key_exists('poznam', $structure)) { - $dataForInsert['poznam'] = $this->poznam.' '.$code; + $dataForInsert['poznam'] = $this->poznam . ' ' . $code; } if (array_key_exists('nazev', $structure)) { - $dataForInsert['nazev'] = $code.' '.$this->poznam.' '; + $dataForInsert['nazev'] = $code . ' ' . $this->poznam . ' '; } if (array_key_exists('kod', $structure)) { @@ -68,18 +67,16 @@ public function getDataForInsert($code = 'UnitTest') * This method is called before a test is executed. * @covers FlexiPeeHP\FlexiBeeRW::__construct */ - protected function setUp(): void - { + protected function setUp(): void { $this->object = new FlexiBeeRW(null, - ['atomic' => false, 'debug' => false]); + ['atomic' => false, 'debug' => false]); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ - protected function tearDown(): void - { + protected function tearDown(): void { } @@ -87,8 +84,7 @@ protected function tearDown(): void * @covers FlexiPeeHP\FlexiBeeRW::performAction * @expectedException \Exception */ - public function testPerformAction() - { + public function testPerformAction() { $actions = $this->object->getActionsInfo(); if (!empty($actions) && count($actions)) { @@ -97,7 +93,7 @@ public function testPerformAction() } if (array_key_exists('storno', $actions)) { - $this->object->insertToFlexiBee($this->getDataForInsert('StornoTest_'.time())); + $this->object->insertToFlexiBee($this->getDataForInsert('StornoTest_' . time())); $this->object->performAction('storno', 'int'); } } @@ -107,18 +103,16 @@ public function testPerformAction() /** * @covers FlexiPeeHP\FlexiBeeRW::timestampToFlexiDate */ - public function testTimestampToFlexiDate() - { + public function testTimestampToFlexiDate() { $this->assertNull($this->object->timestampToFlexiDate()); $this->assertEquals('2016-09-16', - $this->object->timestampToFlexiDate('1474040506')); + $this->object->timestampToFlexiDate('1474040506')); } /** * @covers FlexiPeeHP\FlexiBeeRW::timestampToFlexiDateTime */ - public function testTimestampToFlexiDateTime() - { + public function testTimestampToFlexiDateTime() { $this->assertNull($this->object->timestampToFlexiDateTime()); $flexiDateTime = $this->object->timestampToFlexiDateTime('1474040506'); $this->assertEquals('2016-09-16', substr($flexiDateTime, 0, 10)); @@ -128,8 +122,7 @@ public function testTimestampToFlexiDateTime() /** * @covers FlexiPeeHP\FlexiBeeRW::objectToID */ - public function testObjectToID() - { + public function testObjectToID() { $id = \Ease\Functions::randomNumber(1, 9999); $this->object->setMyKey($id); $this->assertEquals([$id], $this->object->objectToID([$this->object])); @@ -139,8 +132,7 @@ public function testObjectToID() /** * @covers FlexiPeeHP\FlexiBeeRW::getRecordID */ - public function testGetRecordID() - { + public function testGetRecordID() { parent::testGetRecordID(); $structure = $this->object->getEvidenceInfo(); if (!empty($structure) && count($structure) && array_key_exists('kod', $structure)) { @@ -152,78 +144,67 @@ public function testGetRecordID() /** * @covers FlexiPeeHP\FlexiBeeRW::controlMandatoryColumns */ - public function testControlMandatoryColumns() - { + public function testControlMandatoryColumns() { $this->object->controlMandatoryColumns(); } /** * @covers FlexiPeeHP\FlexiBeeRW::controlReadOnlyColumns */ - public function testControlReadOnlyColumns() - { + public function testControlReadOnlyColumns() { $this->object->controlReadOnlyColumns(['id' => 1]); } /** * @covers FlexiPeeHP\FlexiBeeRW::addArrayToBranch */ - public function testAddArrayToBranch() - { + public function testAddArrayToBranch() { $this->object->addArrayToBranch(['nazev' => 'test'], 'podEvidence'); } /** * @covers FlexiPeeHP\FlexiBeeRW::addObjectToBranch */ - public function testAddObjectToBranch() - { + public function testAddObjectToBranch() { $this->object->addObjectToBranch(new \FlexiPeeHP\FakturaVydanaPolozka(['nazev' => 'test'])); } /** * @covers FlexiPeeHP\FlexiBeeRW::vazbaAdd */ - public function testVazbaAdd() - { + public function testVazbaAdd() { $this->object->vazbaAdd(\Ease\Functions::randomNumber()); } /** * @covers FlexiPeeHP\FlexiBeeRW::vazbaDel */ - public function testVazbaDel() - { + public function testVazbaDel() { $this->object->vazbaDel(\Ease\Functions::randomNumber()); } /** * @covers FlexiPeeHP\FlexiBeeRW::getJsonizedData */ - public function testGetJsonizedData() - { + public function testGetJsonizedData() { $this->object->setData(['id' => time(), 'nazev' => \Ease\Functions::randomString(), 'stitky' => ['TEST', 'TESTING']]); $this->object->getJsonizedData(); } - - /** * @covers FlexiPeeHP\FlexiBeeRW::insertToFlexiBee */ - public function testInsertToFlexiBee() - { - $this->object->insertToFlexiBee(['id' => 'ext:test:'.time()]); - $this->object->setData(['id' => 'ext:test:'.time()], true); + public function testInsertToFlexiBee() { + $this->object->insertToFlexiBee(['id' => 'ext:test:' . time()]); + $this->object->setData(['id' => 'ext:test:' . time()], true); $this->object->insertToFlexiBee(); } /** * @covers FlexiPeeHP\FlexiBeeRW::parseResponse */ - public function testParseResponse() - { + public function testParseResponse() { $responseDecoded = array( '@version' => '1.0', 'success' => 'true', @@ -273,16 +254,43 @@ public function testParseResponse() 'ref' => '/c/flexipeehp/adresar-bankovni-ucet/28', ), ), - ) + ) ; $this->object->parseResponse($responseDecoded, 201); } + /** + * @covers FlexiPeeHP\FlexiBeeRW::parseError + */ + public function testParseError() { + parent::testParseResponse(); + + $evBackup = $this->object->getEvidence(); + $this->object->setEvidence('adresar'); + $victim = $this->object->getFirstRecordID(); + + $this->object->postFields = '{"winstrom":{"@version":"1.0","adresar":{"stat":"Y"}}}'; + $this->object->doCurlRequest($this->object->evidenceUrlWithSuffix('/' . $victim), 'PUT', 'json'); + + + $erResponse = $this->object->rawResponseToArray($this->object->lastCurlResponse, $this->object->responseFormat); + + + $this->assertEquals(1, $this->object->parseError($erResponse)); + + $this->object->postFields = '{"winstrom":{"@version":"1.0","adresar":{"X":"Y"}}}'; + $this->object->doCurlRequest($this->object->evidenceUrlWithSuffix('/' . $victim), 'PUT', 'json'); + $erResponse = $this->object->rawResponseToArray($this->object->lastCurlResponse, $this->object->responseFormat); + + $this->assertEquals(1, $this->object->parseError($erResponse)); + + $this->object->setEvidence($evBackup); + } + /** * @covers FlexiPeeHP\FlexiBeeRW::assignResultIDs */ - public function testAssignResultIDs() - { + public function testAssignResultIDs() { $ids = array( 'adresar' => array( @@ -306,8 +314,7 @@ public function testAssignResultIDs() /** * @covers FlexiPeeHP\FlexiBeeRW::extractResultIDs */ - public function testExtractResultIDs() - { + public function testExtractResultIDs() { $resultInfo = array( 0 => array( @@ -351,32 +358,28 @@ public function testExtractResultIDs() /** * @covers FlexiPeeHP\FlexiBeeRW::getLastInsertedId */ - public function testGetLastInsertedId() - { + public function testGetLastInsertedId() { $this->object->getLastInsertedId(); } /** * @covers FlexiPeeHP\FlexiBeeRW::sendUnsent */ - public function testSendUnsent() - { + public function testSendUnsent() { $this->object->sendUnsent(); } /** * @covers FlexiPeeHP\FlexiBeeRW::deleteFromFlexiBee */ - public function testDeleteFromFlexiBee() - { + public function testDeleteFromFlexiBee() { $this->object->deleteFromFlexiBee(); } /** * @covers FlexiPeeHP\FlexiBeeRW::takeData */ - public function testTakeData() - { + public function testTakeData() { $this->object->takeData(['id' => \Ease\Functions::randomNumber()]); } @@ -384,8 +387,7 @@ public function testTakeData() * @after * @covers FlexiPeeHP\FlexiBeeRW::getDataForJSON */ - public function testGetDataForJSON() - { + public function testGetDataForJSON() { $this->object->setData(['name' => 'test']); $this->object->getDataForJSON(); } @@ -393,33 +395,31 @@ public function testGetDataForJSON() /** * @covers FlexiPeeHP\FlexiBeeRW::addExternalID */ - public function testAddExternalID() - { + public function testAddExternalID() { if (empty($this->object->getEvidence())) { $this->object->setEvidence('banka'); } - $this->object->addExternalID('ext:test:'.\Ease\Functions::randomNumber()); + $this->object->addExternalID('ext:test:' . \Ease\Functions::randomNumber()); } /** * @covers FlexiPeeHP\FlexiBeeRW::changeExternalID */ - public function testChangeExternalID() - { + public function testChangeExternalID() { $this->object->changeExternalID('test', \Ease\Functions::randomNumber(), - \Ease\Functions::randomNumber()); + \Ease\Functions::randomNumber()); } /** * @covers FlexiPeeHP\FlexiBeeRW::sync */ - public function testSync() - { + public function testSync() { $code = \Ease\Functions::randomString(); - $this->assertFalse($this->object->sync(['kod' => $code.'X'])); + $this->assertFalse($this->object->sync(['kod' => $code . 'X'])); if ($this->object->getEvidence()) { $syncResult = $this->object->sync($this->getDataForInsert($code)); $this->assertTrue($syncResult); } } + }