Permalink
Browse files

Added initial basic unit test for Party and Opportunity

  • Loading branch information...
1 parent 91abffb commit 66cd5b9b974ed7354603606e7f1fad923e3ac036 David Coallier committed Apr 1, 2010
Showing with 358 additions and 0 deletions.
  1. +114 −0 tests/AllTests.php
  2. +70 −0 tests/CapsuleOpportunityTestCase.php
  3. +78 −0 tests/CapsulePartyTestCase.php
  4. +92 −0 tests/CapsuleTestCase.php
  5. +4 −0 tests/config.ini-dist
View
@@ -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 <david@echolibre.com> |
+ * +-----------------------------------------------------------------------+
+ *
+ * PHP version 5
+ *
+ * @category Services
+ * @package Services_Capsule
+ * @author David Coallier <david@echolibre.com>
+ * @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 <david@echolibre.com>
+ * @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();
+}
@@ -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 <david@echolibre.com> |
+ * +-----------------------------------------------------------------------+
+ *
+ * PHP version 5
+ *
+ * @category Services
+ * @package Services_Capsule
+ * @author David Coallier <david@echolibre.com>
+ * @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 <david@echolibre.com>
+ * @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']);
+ }
+}
@@ -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 <david@echolibre.com> |
+ * +-----------------------------------------------------------------------+
+ *
+ * PHP version 5
+ *
+ * @category Services
+ * @package Services_Capsule
+ * @author David Coallier <david@echolibre.com>
+ * @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 <david@echolibre.com>
+ * @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']);
+ }
+}
@@ -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 <david@echolibre.com> |
+ * +-----------------------------------------------------------------------+
+ *
+ * PHP version 5
+ *
+ * @category Services
+ * @package Services_Capsule
+ * @author David Coallier <david@echolibre.com>
+ * @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 <david@echolibre.com>
+ * @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);
+ }
+}
@@ -0,0 +1,4 @@
+partyId = 0
+appName = sample
+token = yourtoken
+opportunityId = someOpportunityId

0 comments on commit 66cd5b9

Please sign in to comment.