Skip to content

Commit

Permalink
Added initial basic unit test for Party and Opportunity
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coallier committed Apr 1, 2010
1 parent 91abffb commit 66cd5b9
Show file tree
Hide file tree
Showing 5 changed files with 358 additions and 0 deletions.
114 changes: 114 additions & 0 deletions tests/AllTests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php
/**
* +-----------------------------------------------------------------------+
* | Copyright (c) 2010, David Coallier |
* | All rights reserved. |
* | |
* | Redistribution and use in source and binary forms, with or without |
* | modification, are permitted provided that the following conditions |
* | are met: |
* | |
* | o Redistributions of source code must retain the above copyright |
* | notice, this list of conditions and the following disclaimer. |
* | o Redistributions in binary form must reproduce the above copyright |
* | notice, this list of conditions and the following disclaimer in the |
* | documentation and/or other materials provided with the distribution.|
* | o The names of the authors may not be used to endorse or promote |
* | products derived from this software without specific prior written |
* | permission. |
* | |
* | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
* | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
* | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
* | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
* | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
* | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
* | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* | |
* +-----------------------------------------------------------------------+
* | Author: David Coallier <[email protected]> |
* +-----------------------------------------------------------------------+
*
* PHP version 5
*
* @category Services
* @package Services_Capsule
* @author David Coallier <[email protected]>
* @copyright echolibre ltd. 2009-2010
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @version GIT: $Id$
*/

$version = '@package_version@';
if (strstr($version, 'package_version')) {
set_include_path(dirname(dirname(__FILE__)) . ':' . get_include_path());
}

if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Services_Capsule_AllTests::main');
}

/**
* PHPUnit related
* @ignore
*/
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';

/**
* TestCase
*/
require_once 'CapsulePartyTestCase.php';
require_once 'CapsuleOpportunityTestCase.php';

/**
* Services_Capsule_AllTests
*
* @category Services
* @package Services_Capsule
* @author David Coallier <[email protected]>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @version Release: @package_version@
*/
class Services_Capsule_AllTests
{
/**
* Launches the TextUI test runner
*
* @return void
* @uses PHPUnit_TextUI_TestRunner
*/
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}

/**
* Adds all class test suites into the master suite
*
* @return PHPUnit_Framework_TestSuite a master test suite
* containing all class test suites
* @uses PHPUnit_Framework_TestSuite
*/
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite(
'Services_Capsule Suite of Unit tests'
);

$suite->addTestSuite('CapsulePartyTestCase');
$suite->addTestSuite('CapsuleOpportunityTestCase');

return $suite;
}
}

if (PHPUnit_MAIN_METHOD == 'Services_Capsule_AllTests::main') {
Services_Capsule_AllTests::main();
}
70 changes: 70 additions & 0 deletions tests/CapsuleOpportunityTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* +-----------------------------------------------------------------------+
* | Copyright (c) 2010, David Coallier |
* | All rights reserved. |
* | |
* | Redistribution and use in source and binary forms, with or without |
* | modification, are permitted provided that the following conditions |
* | are met: |
* | |
* | o Redistributions of source code must retain the above copyright |
* | notice, this list of conditions and the following disclaimer. |
* | o Redistributions in binary form must reproduce the above copyright |
* | notice, this list of conditions and the following disclaimer in the |
* | documentation and/or other materials provided with the distribution.|
* | o The names of the authors may not be used to endorse or promote |
* | products derived from this software without specific prior written |
* | permission. |
* | |
* | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
* | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
* | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
* | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
* | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
* | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
* | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* | |
* +-----------------------------------------------------------------------+
* | Author: David Coallier <[email protected]> |
* +-----------------------------------------------------------------------+
*
* PHP version 5
*
* @category Services
* @package Services_Capsule
* @author David Coallier <[email protected]>
* @copyright echolibre ltd. 2009-2010
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @version GIT: $Id$
*/

/**
* CapsuleTestCase
* @ignore
*/
require_once dirname(__FILE__) . '/CapsuleTestCase.php';

/**
* CapsulePartyTestCase
*
* @category Services
* @package Services_Capsule
* @author David Coallier <[email protected]>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @version Release: @package_version@
*/
class CapsuleOpportunityTestCase extends CapsuleTestCase
{
public function testGetOpportunityById()
{
$opp = $this->capsule->opportunity->get($this->config['opportunityId']);
$this->assertEquals($opp->opportunity->id, $this->config['opportunityId']);
}
}
78 changes: 78 additions & 0 deletions tests/CapsulePartyTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* +-----------------------------------------------------------------------+
* | Copyright (c) 2010, David Coallier |
* | All rights reserved. |
* | |
* | Redistribution and use in source and binary forms, with or without |
* | modification, are permitted provided that the following conditions |
* | are met: |
* | |
* | o Redistributions of source code must retain the above copyright |
* | notice, this list of conditions and the following disclaimer. |
* | o Redistributions in binary form must reproduce the above copyright |
* | notice, this list of conditions and the following disclaimer in the |
* | documentation and/or other materials provided with the distribution.|
* | o The names of the authors may not be used to endorse or promote |
* | products derived from this software without specific prior written |
* | permission. |
* | |
* | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
* | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
* | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
* | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
* | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
* | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
* | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* | |
* +-----------------------------------------------------------------------+
* | Author: David Coallier <[email protected]> |
* +-----------------------------------------------------------------------+
*
* PHP version 5
*
* @category Services
* @package Services_Capsule
* @author David Coallier <[email protected]>
* @copyright echolibre ltd. 2009-2010
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @version GIT: $Id$
*/

/**
* CapsuleTestCase
* @ignore
*/
require_once dirname(__FILE__) . '/CapsuleTestCase.php';

/**
* CapsulePartyTestCase
*
* @category Services
* @package Services_Capsule
* @author David Coallier <[email protected]>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @version Release: @package_version@
*/
class CapsulePartyTestCase extends CapsuleTestCase
{
/**
* @expectedException Services_Capsule_RuntimeException
*/
public function testMagicGetException()
{
$this->capsule->random->test();
}

public function testGetPartyById()
{
$party = $this->capsule->party->get($this->config['partyId']);
$this->assertEquals($party->person->id, $this->config['partyId']);
}
}
92 changes: 92 additions & 0 deletions tests/CapsuleTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
/**
* +-----------------------------------------------------------------------+
* | Copyright (c) 2010, David Coallier |
* | All rights reserved. |
* | |
* | Redistribution and use in source and binary forms, with or without |
* | modification, are permitted provided that the following conditions |
* | are met: |
* | |
* | o Redistributions of source code must retain the above copyright |
* | notice, this list of conditions and the following disclaimer. |
* | o Redistributions in binary form must reproduce the above copyright |
* | notice, this list of conditions and the following disclaimer in the |
* | documentation and/or other materials provided with the distribution.|
* | o The names of the authors may not be used to endorse or promote |
* | products derived from this software without specific prior written |
* | permission. |
* | |
* | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
* | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
* | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
* | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
* | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
* | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
* | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* | |
* +-----------------------------------------------------------------------+
* | Author: David Coallier <[email protected]> |
* +-----------------------------------------------------------------------+
*
* PHP version 5
*
* @category Services
* @package Services_Capsule
* @author David Coallier <[email protected]>
* @copyright echolibre ltd. 2009-2010
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @version GIT: $Id$
*/

/**
* CapsuleTestCase
* @ignore
*/
require_once 'Services/Capsule.php';

/**
* CapsuleTestCase
*
* @category Services
* @package Services_Capsule
* @author David Coallier <[email protected]>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @version Release: @package_version@
*/
abstract class CapsuleTestCase extends PHPUnit_Framework_TestCase
{
protected $config;

protected $capsule;

public function setUp()
{
$config = dirname(__FILE__) . '/config.ini';

if (!file_exists($config)) {
$this->markTestIncomplete(
'You need a config.ini file in order to run the tests.'
);
}

$this->config = parse_ini_file($config);

$this->capsule = new Services_Capsule(
$this->config['appName'],
$this->config['token']
);
}

public function tearDown()
{
unset($this->config);
unset($this->capsule);
}
}
4 changes: 4 additions & 0 deletions tests/config.ini-dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
partyId = 0
appName = sample
token = yourtoken
opportunityId = someOpportunityId

0 comments on commit 66cd5b9

Please sign in to comment.