-
Notifications
You must be signed in to change notification settings - Fork 0
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 #55 from cultuurnet/feature/III-2331
Feature/iii 2331
- Loading branch information
Showing
6 changed files
with
360 additions
and
0 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
51 changes: 51 additions & 0 deletions
51
CultureFeed/test/uitpas/CultureFeed_Uitpas_CardSystemsTest.php
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,51 @@ | ||
<?php | ||
|
||
class CultureFeed_Uitpas_CardSystemsTest extends PHPUnit_Framework_TestCase { | ||
|
||
const ORGANIZERCDBID = "47B6FA21-ACB1-EA8F-2C231182C7DD0A19"; | ||
|
||
public function testGetCardSystemsForOrganizer() { | ||
/** @var CultureFeed_OAuthClient|PHPUnit_Framework_MockObject_MockObject $oauth_client_stub */ | ||
$oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); | ||
|
||
$get_xml = file_get_contents(dirname(__FILE__) . '/data/cardsystems/get.xml'); | ||
|
||
$oauth_client_stub->expects($this->once()) | ||
->method('consumerGetAsXML') | ||
->will($this->returnValue($get_xml)); | ||
|
||
$cf = new CultureFeed($oauth_client_stub); | ||
|
||
$data = $cf->uitpas()->getCardSystemsForOrganizer(self::ORGANIZERCDBID); | ||
|
||
$this->assertInstanceOf('CultureFeed_ResultSet', $data); | ||
|
||
$this->assertContainsOnly('CultureFeed_Uitpas_CardSystem', $data->objects); | ||
$this->assertCount(2, $data->objects); | ||
$this->assertEquals(2, $data->total); | ||
|
||
/* @var \CultureFeed_Uitpas_CardSystem $cardSystem */ | ||
$cardSystem = reset($data->objects); | ||
|
||
$this->assertEquals(1, $cardSystem->id); | ||
$this->assertEquals("UiTPAS Dender", $cardSystem->name); | ||
|
||
$this->assertContainsOnly('CultureFeed_Uitpas_DistributionKey', $cardSystem->distributionKeys); | ||
$this->assertCount(3, $cardSystem->distributionKeys); | ||
|
||
$this->assertEquals(25, $cardSystem->distributionKeys[0]->id); | ||
$this->assertEquals('25% meerdaags (regio)', $cardSystem->distributionKeys[0]->name); | ||
|
||
$this->assertEquals(23, $cardSystem->distributionKeys[1]->id); | ||
$this->assertEquals('€1,5 dag (regio)', $cardSystem->distributionKeys[1]->name); | ||
|
||
$this->assertEquals(24, $cardSystem->distributionKeys[2]->id); | ||
$this->assertEquals('€3 hele dag (regio)', $cardSystem->distributionKeys[2]->name); | ||
|
||
$cardSystem = next($data->objects); | ||
|
||
$this->assertEquals(15, $cardSystem->id); | ||
$this->assertEquals("UiTPAS", $cardSystem->name); | ||
$this->assertEmpty($cardSystem->distributionKeys); | ||
} | ||
} |
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,131 @@ | ||
<?php | ||
|
||
class CultureFeed_Uitpas_Event_CardSystemsTest extends PHPUnit_Framework_TestCase { | ||
const EVENTCDBID = "47B6FA21-ACB1-EA8F-2C231182C7DD0A19"; | ||
|
||
public function testGetCardSystemsForEvent() { | ||
/** @var CultureFeed_OAuthClient|PHPUnit_Framework_MockObject_MockObject $oauth_client_stub */ | ||
$oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); | ||
|
||
$get_xml = file_get_contents(dirname(__FILE__) . '/../data/cultureevent/getCardSystems.xml'); | ||
|
||
$oauth_client_stub->expects($this->once()) | ||
->method('consumerGetAsXML') | ||
->will($this->returnValue($get_xml)); | ||
|
||
$cf = new CultureFeed($oauth_client_stub); | ||
|
||
$data = $cf->uitpas()->getCardSystemsForEvent(self::EVENTCDBID); | ||
|
||
$this->assertInstanceOf('CultureFeed_ResultSet', $data); | ||
|
||
$this->assertContainsOnly('CultureFeed_Uitpas_CardSystem', $data->objects); | ||
$this->assertCount(1, $data->objects); | ||
$this->assertEquals(1, $data->total); | ||
|
||
/* @var \CultureFeed_Uitpas_CardSystem $cardSystem */ | ||
$cardSystem = reset($data->objects); | ||
|
||
$this->assertEquals(1, $cardSystem->id); | ||
$this->assertEquals("UiTPAS Dender", $cardSystem->name); | ||
|
||
$this->assertContainsOnly('CultureFeed_Uitpas_DistributionKey', $cardSystem->distributionKeys); | ||
$this->assertCount(1, $cardSystem->distributionKeys); | ||
|
||
$this->assertEquals(27, $cardSystem->distributionKeys[0]->id); | ||
$this->assertEquals('Speelplein HA', $cardSystem->distributionKeys[0]->name); | ||
} | ||
|
||
/** | ||
* Test the registering of an event. | ||
*/ | ||
public function testAddCardSystemToEvent() { | ||
|
||
$response = <<<XML | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<response> | ||
<code>ACTION_SUCCEEDED</code> | ||
<cardSystems> | ||
<cardSystem> | ||
<id>1</id> | ||
<name>UiTPAS Dender</name> | ||
<distributionKeys> | ||
<distributionKey> | ||
<id>27</id> | ||
<name>Speelplein HA</name> | ||
<conditions> | ||
<condition> | ||
<definition>KANSARM</definition> | ||
<operator>IN</operator> | ||
<value>MY_CARDSYSTEM</value> | ||
</condition> | ||
</conditions> | ||
<tariff>3.0</tariff> | ||
<priceClasses> | ||
<priceClass> | ||
<name>Basistarief</name> | ||
<price>10.0</price> | ||
<tariff>3.0</tariff> | ||
</priceClass> | ||
</priceClasses> | ||
<automatic>false</automatic> | ||
</distributionKey> | ||
</distributionKeys> | ||
</cardSystem> | ||
</cardSystems> | ||
</response> | ||
XML; | ||
|
||
/** @var CultureFeed_OAuthClient|PHPUnit_Framework_MockObject_MockObject $oauth_client_stub */ | ||
$oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); | ||
$oauth_client_stub | ||
->expects($this->once()) | ||
->method('consumerPostAsXml') | ||
->with($this->equalTo('uitpas/cultureevent/' . self::EVENTCDBID . '/cardsystems')) | ||
->will($this->returnValue($response)); | ||
|
||
$cf = new CultureFeed($oauth_client_stub); | ||
|
||
$response = $cf->uitpas()->addCardSystemToEvent(self::EVENTCDBID, 1, 27); | ||
|
||
$this->assertInstanceOf('\CultureFeed_Uitpas_Response', $response); | ||
|
||
$this->assertEquals('ACTION_SUCCEEDED', $response->code); | ||
$this->assertNull($response->message); | ||
} | ||
|
||
public function testDeleteCardSystemFromEvent() { | ||
|
||
$response = <<<XML | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<response> | ||
<code>ACTION_SUCCEEDED</code> | ||
<cardSystems/> | ||
</response> | ||
XML; | ||
|
||
$cardSystemId = 1; | ||
|
||
/** @var CultureFeed_OAuthClient|PHPUnit_Framework_MockObject_MockObject $oauth_client_stub */ | ||
$oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); | ||
$oauth_client_stub | ||
->expects($this->once()) | ||
->method('request') | ||
->with( | ||
'uitpas/cultureevent/' . self::EVENTCDBID . '/cardsystems/' . $cardSystemId, | ||
[], | ||
'DELETE', | ||
FALSE | ||
) | ||
->willReturn($response); | ||
|
||
$cf = new CultureFeed($oauth_client_stub); | ||
|
||
$response = $cf->uitpas()->deleteCardSystemFromEvent(self::EVENTCDBID, $cardSystemId); | ||
|
||
$this->assertInstanceOf('\CultureFeed_Uitpas_Response', $response); | ||
|
||
$this->assertEquals('ACTION_SUCCEEDED', $response->code); | ||
$this->assertNull($response->message); | ||
} | ||
} |
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,31 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<response> | ||
<cardSystems> | ||
<cardSystem> | ||
<distributionKeys> | ||
<distributionKey> | ||
<global>false</global> | ||
<id>25</id> | ||
<name>25% meerdaags (regio)</name> | ||
</distributionKey> | ||
<distributionKey> | ||
<global>false</global> | ||
<id>23</id> | ||
<name>€1,5 dag (regio)</name> | ||
</distributionKey> | ||
<distributionKey> | ||
<global>false</global> | ||
<id>24</id> | ||
<name>€3 hele dag (regio)</name> | ||
</distributionKey> | ||
</distributionKeys> | ||
<id>1</id> | ||
<name>UiTPAS Dender</name> | ||
</cardSystem> | ||
<cardSystem> | ||
<distributionKeys/> | ||
<id>15</id> | ||
<name>UiTPAS</name> | ||
</cardSystem> | ||
</cardSystems> | ||
</response> |
32 changes: 32 additions & 0 deletions
32
CultureFeed/test/uitpas/data/cultureevent/getCardSystems.xml
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,32 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<response> | ||
<code>ACTION_SUCCEEDED</code> | ||
<cardSystems> | ||
<cardSystem> | ||
<id>1</id> | ||
<name>UiTPAS Dender</name> | ||
<distributionKeys> | ||
<distributionKey> | ||
<id>27</id> | ||
<name>Speelplein HA</name> | ||
<conditions> | ||
<condition> | ||
<definition>KANSARM</definition> | ||
<operator>IN</operator> | ||
<value>MY_CARDSYSTEM</value> | ||
</condition> | ||
</conditions> | ||
<tariff>3.0</tariff> | ||
<priceClasses> | ||
<priceClass> | ||
<name>Basistarief</name> | ||
<price>10.0</price> | ||
<tariff>3.0</tariff> | ||
</priceClass> | ||
</priceClasses> | ||
<automatic>false</automatic> | ||
</distributionKey> | ||
</distributionKeys> | ||
</cardSystem> | ||
</cardSystems> | ||
</response> |