Renaming Namespaces and Organizing Classes

- Updated OpenId classes to be in API namespace
- Updated PP Naming Convention to PayPal Naming Convention
- FormatConverter Class got its own namespace
- Handlers are grouped in Handler namespace
- Samples and Tests Updated Accordingly
This commit is contained in:
japatel
2014-12-17 17:15:01 -06:00
parent 4cb951f8b2
commit 9c0827643b
246 changed files with 1067 additions and 1057 deletions

View File

@@ -1,9 +1,9 @@
<?php
namespace PayPal\Test\Common;
use PayPal\Common\PPModel;
use PayPal\Common\PayPalModel;
class ArrayClass extends PPModel
class ArrayClass extends PayPalModel
{
public function setName($name)
@@ -38,4 +38,4 @@ class ArrayClass extends PPModel
{
return $this->tags;
}
}
}

View File

@@ -1,24 +1,24 @@
<?php
namespace PayPal\Test\Common;
use PayPal\Common\PPArrayUtil;
class ArrayUtilTest extends \PHPUnit_Framework_TestCase
{
public function testIsAssocArray()
{
$arr = array(1, 2, 3);
$this->assertEquals(false, PPArrayUtil::isAssocArray($arr));
$arr = array(
'name' => 'John Doe',
'City' => 'San Jose'
);
$this->assertEquals(true, PPArrayUtil::isAssocArray($arr));
$arr[] = 'CA';
$this->assertEquals(false, PPArrayUtil::isAssocArray($arr));
}
}
<?php
namespace PayPal\Test\Common;
use PayPal\Common\ArrayUtil;
class ArrayUtilTest extends \PHPUnit_Framework_TestCase
{
public function testIsAssocArray()
{
$arr = array(1, 2, 3);
$this->assertEquals(false, ArrayUtil::isAssocArray($arr));
$arr = array(
'name' => 'John Doe',
'City' => 'San Jose'
);
$this->assertEquals(true, ArrayUtil::isAssocArray($arr));
$arr[] = 'CA';
$this->assertEquals(false, ArrayUtil::isAssocArray($arr));
}
}

View File

@@ -1,9 +1,9 @@
<?php
namespace PayPal\Test\Common;
use PayPal\Common\PPModel;
use PayPal\Common\PayPalModel;
class ChildClass extends SimpleClass
{
}
}

View File

@@ -5,8 +5,8 @@ use PayPal\Api\Amount;
use PayPal\Api\Currency;
use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Common\FormatConverter;
use PayPal\Common\PPModel;
use PayPal\Converter\FormatConverter;
use PayPal\Common\PayPalModel;
use PayPal\Test\Validation\NumericValidatorTest;
class FormatConverterTest extends \PHPUnit_Framework_TestCase
@@ -118,7 +118,7 @@ class FormatConverterTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider apiModelSettersProvider
*
* @param PPModel $class Class Object
* @param PayPalModel $class Class Object
* @param string $method Method Name where the format is being applied
* @param array $values array of ['input', 'expectedResponse'] is provided
*/

View File

@@ -1,7 +1,7 @@
<?php
namespace PayPal\Test\Common;
use PayPal\Core\PPConfigManager;
use PayPal\Core\PayPalConfigManager;
class ModelTest extends \PHPUnit_Framework_TestCase
{
@@ -90,7 +90,7 @@ class ModelTest extends \PHPUnit_Framework_TestCase
try {
$obj->invalid = "value2";
$this->assertEquals($obj->invalid, "value2");
if (PPConfigManager::getInstance()->get('validation.level') == 'strict') {
if (PayPalConfigManager::getInstance()->get('validation.level') == 'strict') {
$this->fail("It should have thrown a Notice Error");
}
} catch (\PHPUnit_Framework_Error_Notice $ex) {
@@ -100,7 +100,7 @@ class ModelTest extends \PHPUnit_Framework_TestCase
public function testInvalidMagicMethodWithDisabledValidation()
{
PPConfigManager::getInstance()->addConfigs(array('validation.level' => 'disabled'));
PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'disabled'));
$obj = new SimpleClass();
try {
$obj->invalid = "value2";
@@ -108,16 +108,16 @@ class ModelTest extends \PHPUnit_Framework_TestCase
} catch (\PHPUnit_Framework_Error_Notice $ex) {
$this->fail("It should not have thrown a Notice Error as it is disabled.");
}
PPConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict'));
PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict'));
}
public function testInvalidMagicMethodWithValidationLevel()
{
PPConfigManager::getInstance()->addConfigs(array('validation.level' => 'log'));
PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'log'));
$obj = new SimpleClass();
$obj->invalid2 = "value2";
$this->assertEquals($obj->invalid2, "value2");
PPConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict'));
PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict'));
}
public function testArrayClassConversion()

View File

@@ -1,9 +1,9 @@
<?php
namespace PayPal\Test\Common;
use PayPal\Common\PPModel;
use PayPal\Common\PayPalModel;
class NestedClass extends PPModel
class NestedClass extends PayPalModel
{
public function setId($id)
@@ -33,4 +33,4 @@ class NestedClass extends PPModel
{
return $this->info;
}
}
}

View File

@@ -1,8 +1,8 @@
<?php
use PayPal\Common\PPModel;
use PayPal\Common\PayPalModel;
class SimpleModelTestClass extends PPModel
class SimpleModelTestClass extends PayPalModel
{
/**
*
@@ -49,7 +49,7 @@ class SimpleModelTestClass extends PPModel
}
class ContainerModelTestClass extends PPModel
class ContainerModelTestClass extends PayPalModel
{
/**
@@ -97,7 +97,7 @@ class ContainerModelTestClass extends PPModel
}
class ListModelTestClass extends PPModel
class ListModelTestClass extends PayPalModel
{
/**
@@ -145,10 +145,10 @@ class ListModelTestClass extends PPModel
}
/**
* Test class for PPModel.
* Test class for PayPalModel.
*
*/
class PPModelTest extends PHPUnit_Framework_TestCase
class PayPalModelTest extends PHPUnit_Framework_TestCase
{
/**
* Sets up the fixture, for example, opens a network connection.
@@ -245,4 +245,4 @@ class PPModelTest extends PHPUnit_Framework_TestCase
$this->assertEquals($parent, $parentCopy);
}
}
}

View File

@@ -1,9 +1,9 @@
<?php
namespace PayPal\Test\Common;
use PayPal\Common\PPModel;
use PayPal\Common\PayPalModel;
class SimpleClass extends PPModel
class SimpleClass extends PayPalModel
{
public function setName($name)
@@ -25,4 +25,4 @@ class SimpleClass extends PPModel
{
return $this->description;
}
}
}

View File

@@ -1,28 +1,28 @@
<?php
use PayPal\Common\PPUserAgent;
class UserAgentTest extends PHPUnit_Framework_TestCase
{
public function testGetValue()
{
$ua = PPUserAgent::getValue("name", "version");
list($id, $version, $features) = sscanf($ua, "PayPalSDK/%s %s (%s)");
// Check that we pass the useragent in the expected format
$this->assertNotNull($id);
$this->assertNotNull($version);
$this->assertNotNull($features);
$this->assertEquals("name", $id);
$this->assertEquals("version", $version);
// Check that we pass in these mininal features
$this->assertThat($features, $this->stringContains("OS="));
$this->assertThat($features, $this->stringContains("Bit="));
$this->assertThat($features, $this->stringContains("Lang="));
$this->assertThat($features, $this->stringContains("V="));
$this->assertGreaterThan(5, count(explode(';', $features)));
}
}
<?php
use PayPal\Common\PayPalUserAgent;
class UserAgentTest extends PHPUnit_Framework_TestCase
{
public function testGetValue()
{
$ua = PayPalUserAgent::getValue("name", "version");
list($id, $version, $features) = sscanf($ua, "PayPalSDK/%s %s (%s)");
// Check that we pass the useragent in the expected format
$this->assertNotNull($id);
$this->assertNotNull($version);
$this->assertNotNull($features);
$this->assertEquals("name", $id);
$this->assertEquals("version", $version);
// Check that we pass in these mininal features
$this->assertThat($features, $this->stringContains("OS="));
$this->assertThat($features, $this->stringContains("Bit="));
$this->assertThat($features, $this->stringContains("Lang="));
$this->assertThat($features, $this->stringContains("V="));
$this->assertGreaterThan(5, count(explode(';', $features)));
}
}