-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from JindrichPilar/3.x
Fix parseOutput undefined property (closes #90)
- Loading branch information
Showing
10 changed files
with
198 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
|
||
namespace Skaut\Skautis\Wsdl; | ||
|
||
/** | ||
* Thrown when parsing Skautis response fails | ||
*/ | ||
class ParsingFailedException extends WsdlException | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
|
||
namespace Skaut\Skautis\Test\Unit\WebService; | ||
|
||
|
||
|
||
use PHPUnit\Framework\TestCase; | ||
use Skaut\Skautis\Wsdl\WebService; | ||
use Skaut\Skautis\Wsdl\WebServiceInterface; | ||
|
||
class ParsingSOAPOutputTest extends TestCase | ||
{ | ||
|
||
protected function tearDown(): void | ||
{ | ||
\Mockery::close(); | ||
} | ||
|
||
private function loadData(string $methodName): \stdClass { | ||
$filePath = __DIR__.'/resources/'.$methodName.'.txt'; | ||
|
||
if (!file_exists($filePath) || !is_readable($filePath)) { | ||
throw new \RuntimeException("Cannot access file '$filePath'"); | ||
} | ||
|
||
$text = file_get_contents($filePath); | ||
|
||
return unserialize($text, ['allowed_classes' => [\stdClass::class]]); | ||
} | ||
|
||
private function createMockedWebService(\stdClass $data): WebServiceInterface { | ||
$client = \Mockery::mock(\SoapClient::class); | ||
$client->shouldReceive('__soapCall')->once()->andReturn($data); | ||
|
||
return new WebService($client, [], null); | ||
} | ||
|
||
public function testObjectForExistentRecord(): void { | ||
$service = $this->createMockedWebService($this->loadData(__FUNCTION__)); | ||
|
||
$result = $service->unitDetail(['ID' => 24404]); | ||
|
||
$this->assertNotNull($result); | ||
$this->assertInstanceOf(\stdClass::class, $result); | ||
$this->assertSame('Středisko', $result->UnitType); | ||
} | ||
|
||
public function testNullForNonExistentRecord(): void { | ||
$service = $this->createMockedWebService($this->loadData(__FUNCTION__)); | ||
|
||
$result = $service->unitDetail(['ID' => 999]); | ||
|
||
$this->assertNull($result); | ||
} | ||
|
||
public function testArrayOfResults(): void { | ||
$service = $this->createMockedWebService($this->loadData(__FUNCTION__)); | ||
|
||
$results = $service->unitAll(['ID_UnitParent' => 24404]); | ||
|
||
$this->assertIsArray($results); | ||
$this->assertCount(5, $results); | ||
|
||
foreach ($results as $result) { | ||
$this->assertInstanceOf(\stdClass::class, $result); | ||
} | ||
} | ||
|
||
public function testEmptyArrayOfResults(): void { | ||
$service = $this->createMockedWebService($this->loadData(__FUNCTION__)); | ||
|
||
$result = $service->unitAll(['ID_UnitParent' => 999]); | ||
|
||
$this->assertIsArray($result); | ||
$this->assertCount(0, $result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
O:8:"stdClass":1:{s:13:"UnitAllResult";O:8:"stdClass":1:{s:13:"UnitAllOutput";a:5:{i:0;O:8:"stdClass":21:{s:2:"ID";i:24405;s:8:"ID_Group";i:762137;s:11:"ID_UnitType";s:5:"oddil";s:8:"UnitType";s:6:"Oddíl";s:11:"DisplayName";s:11:"Medvíďata";s:8:"SortName";s:26:"621.24.024-1 - Medvíďata";s:18:"RegistrationNumber";s:12:"621.24.024-1";s:23:"ShortRegistrationNumber";s:5:"024-1";s:8:"Location";s:7:"BLANSKO";s:2:"IC";s:0:"";s:6:"Street";s:16:"Pod Resslem 1978";s:11:"PostalState";s:0:"";s:4:"City";s:7:"BLANSKO";s:8:"Postcode";s:5:"67902";s:5:"State";s:17:"Česká republika";s:15:"PostalFirstLine";s:0:"";s:12:"PostalStreet";s:0:"";s:10:"PostalCity";s:0:"";s:14:"PostalPostcode";s:0:"";s:4:"Note";s:0:"";s:15:"FullDisplayName";s:11:"Medvíďata";}i:1;O:8:"stdClass":21:{s:2:"ID";i:24406;s:8:"ID_Group";i:762138;s:11:"ID_UnitType";s:5:"oddil";s:8:"UnitType";s:6:"Oddíl";s:11:"DisplayName";s:10:"Permoníci";s:8:"SortName";s:25:"621.24.024-2 - Permoníci";s:18:"RegistrationNumber";s:12:"621.24.024-2";s:23:"ShortRegistrationNumber";s:5:"024-2";s:8:"Location";s:7:"BLANSKO";s:2:"IC";s:0:"";s:6:"Street";s:18:"Na Drážkách 941";s:11:"PostalState";s:0:"";s:4:"City";s:7:"BLANSKO";s:8:"Postcode";s:5:"67902";s:5:"State";s:17:"Česká republika";s:15:"PostalFirstLine";s:0:"";s:12:"PostalStreet";s:0:"";s:10:"PostalCity";s:0:"";s:14:"PostalPostcode";s:0:"";s:4:"Note";s:0:"";s:15:"FullDisplayName";s:10:"Permoníci";}i:2;O:8:"stdClass":21:{s:2:"ID";i:24407;s:8:"ID_Group";i:762139;s:11:"ID_UnitType";s:5:"oddil";s:8:"UnitType";s:6:"Oddíl";s:11:"DisplayName";s:9:"3. oddíl";s:8:"SortName";s:24:"621.24.024-3 - 3. oddíl";s:18:"RegistrationNumber";s:12:"621.24.024-3";s:23:"ShortRegistrationNumber";s:5:"024-3";s:8:"Location";s:7:"BLANSKO";s:2:"IC";s:0:"";s:6:"Street";s:17:"Vrchlického 2535";s:11:"PostalState";s:0:"";s:4:"City";s:7:"BLANSKO";s:8:"Postcode";s:5:"67902";s:5:"State";s:17:"Česká republika";s:15:"PostalFirstLine";s:0:"";s:12:"PostalStreet";s:0:"";s:10:"PostalCity";s:0:"";s:14:"PostalPostcode";s:0:"";s:4:"Note";s:0:"";s:15:"FullDisplayName";s:9:"3. oddíl";}i:3;O:8:"stdClass":21:{s:2:"ID";i:24408;s:8:"ID_Group";i:762140;s:11:"ID_UnitType";s:5:"oddil";s:8:"UnitType";s:6:"Oddíl";s:11:"DisplayName";s:6:"Zámek";s:8:"SortName";s:21:"621.24.024-4 - Zámek";s:18:"RegistrationNumber";s:12:"621.24.024-4";s:23:"ShortRegistrationNumber";s:5:"024-4";s:8:"Location";s:7:"BLANSKO";s:2:"IC";s:0:"";s:6:"Street";s:16:"U včelína 1192";s:11:"PostalState";s:0:"";s:4:"City";s:7:"BLANSKO";s:8:"Postcode";s:5:"67902";s:5:"State";s:17:"Česká republika";s:15:"PostalFirstLine";s:0:"";s:12:"PostalStreet";s:0:"";s:10:"PostalCity";s:0:"";s:14:"PostalPostcode";s:0:"";s:4:"Note";s:0:"";s:15:"FullDisplayName";s:6:"Zámek";}i:4;O:8:"stdClass":21:{s:2:"ID";i:24409;s:8:"ID_Group";i:762141;s:11:"ID_UnitType";s:5:"oddil";s:8:"UnitType";s:6:"Oddíl";s:11:"DisplayName";s:9:"Jitřenky";s:8:"SortName";s:24:"621.24.024-5 - Jitřenky";s:18:"RegistrationNumber";s:12:"621.24.024-5";s:23:"ShortRegistrationNumber";s:5:"024-5";s:8:"Location";s:7:"BLANSKO";s:2:"IC";s:0:"";s:6:"Street";s:14:"Jarošova 1137";s:11:"PostalState";s:0:"";s:4:"City";s:7:"BLANSKO";s:8:"Postcode";s:5:"67902";s:5:"State";s:17:"Česká republika";s:15:"PostalFirstLine";s:0:"";s:12:"PostalStreet";s:0:"";s:10:"PostalCity";s:0:"";s:14:"PostalPostcode";s:0:"";s:4:"Note";s:0:"";s:15:"FullDisplayName";s:9:"Jitřenky";}}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
O:8:"stdClass":1:{s:13:"UnitAllResult";O:8:"stdClass":0:{}} |
1 change: 1 addition & 0 deletions
1
tests/Unit/WebService/resources/testNullForNonExistentRecord.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
O:8:"stdClass":0:{} |
1 change: 1 addition & 0 deletions
1
tests/Unit/WebService/resources/testObjectForExistentRecord.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
O:8:"stdClass":1:{s:16:"UnitDetailResult";O:8:"stdClass":48:{s:8:"ID_Login";s:36:"00000000-0000-0000-0000-000000000000";s:2:"ID";i:24404;s:8:"ID_Group";i:762136;s:7:"ID_Unit";i:0;s:11:"ID_UnitType";s:9:"stredisko";s:8:"UnitType";s:10:"Středisko";s:15:"ContainsMembers";b:1;s:18:"CommissionDeadline";i:14;s:11:"DisplayName";s:15:"Žlutý kvítek";s:8:"SortName";s:24:"621.24 - Žlutý kvítek";s:18:"RegistrationNumber";s:6:"621.24";s:23:"ShortRegistrationNumber";s:6:"621.24";s:8:"Location";s:7:"BLANSKO";s:2:"IC";s:8:"11225073";s:10:"IsVatPayer";b:1;s:3:"DIC";s:10:"CZ11225073";s:6:"Street";s:14:"Bezručova 556";s:4:"City";s:7:"BLANSKO";s:8:"Postcode";s:5:"67902";s:5:"State";s:17:"Česká republika";s:15:"PostalFirstLine";s:0:"";s:12:"PostalStreet";s:0:"";s:10:"PostalCity";s:0:"";s:14:"PostalPostcode";s:0:"";s:11:"PostalState";s:0:"";s:4:"Note";s:0:"";s:11:"ID_TroopArt";N;s:27:"CanUpdateRegistrationNumber";b:0;s:12:"IsUnitCancel";b:1;s:13:"JournalParent";b:1;s:17:"ChangeFreeJournal";b:1;s:13:"ID_UnitParent";i:23506;s:12:"OnlyValidate";N;s:21:"IsPostalAuthenticated";N;s:22:"IsAddressAuthenticated";N;s:15:"AddressDistrict";s:7:"Blansko";s:14:"NewDisplayName";s:15:"Žlutý kvítek";s:19:"CompleteDisplayName";s:48:"Junák - český skaut, Žlutý kvítek, , z. s.";s:19:"ID_PersonChangeName";N;s:14:"DateChangeName";N;s:15:"IsPropertyOwner";b:0;s:28:"ID_TempFilePropertyAgreement";N;s:16:"ID_JournalNovice";s:3:"all";s:22:"ID_JournalDeliveryType";s:6:"single";s:15:"FullDisplayName";s:46:"Junák - český skaut, Žlutý kvítek, z. s.";s:19:"ID_DocumentDecision";N;s:28:"ID_DocumentPropertyAgreement";N;s:21:"ID_TempFileSeatChange";N;}} |