Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored and Splitted the SDK #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class CategoriesIntegrationTest extends \PHPUnit_Framework_TestCase
{
/**
* @var $affilinetClient \Affilinet\ProductData\AffilinetClient
* @var $affilinetClient \Affilinet\ProductData\AffilinetProductClient
*/
protected $affilinetClient;

Expand All @@ -26,11 +26,11 @@ protected function setUp()
$log = new \Monolog\Logger('testlog');
$log->pushHandler(new \Monolog\Handler\TestHandler());

$this->affilinetClient = new \Affilinet\ProductData\AffilinetClient(
$this->affilinetClient = new \Affilinet\ProductData\AffilinetProductClient(
[
'log' => $log,
'publisher_id' => \Affilinet\Tests\AffilinetTestCredentials::$publisherId,
'product_webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword,
'webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword,
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SearchProductsIntegrationTest extends \PHPUnit_Framework_TestCase
use VladaHejda\AssertException;

/**
* @var $affilinetClient \Affilinet\ProductData\AffilinetClient
* @var $affilinetClient \Affilinet\ProductData\AffilinetProductClient
*/
protected $affilinetClient;

Expand All @@ -29,11 +29,11 @@ protected function setUp()
$log = new \Monolog\Logger('testlog');
$log->pushHandler(new \Monolog\Handler\TestHandler());

$this->affilinetClient = new \Affilinet\ProductData\AffilinetClient(
$this->affilinetClient = new \Affilinet\ProductData\AffilinetProductClient(
[
'log' => $log,
'publisher_id' => \Affilinet\Tests\AffilinetTestCredentials::$publisherId,
'product_webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword,
'webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword,
]
);

Expand Down Expand Up @@ -74,7 +74,7 @@ public function test400ServerErrorThrows()

$this->assertException(
$test,
\Affilinet\ProductData\Exceptions\AffilinetProductWebserviceException::class,
\Affilinet\Exceptions\AffilinetWebserviceException::class,
0, 'The given SearchProductsRequest is not valid. - The given SearchProductsRequest is not valid. FilterQuery ‘invalidFilterQuery’ is not supported' );
}

Expand All @@ -98,9 +98,8 @@ public function testFindOneReturnsNUllIfNotFound()

public function testFindOneProduct()
{

$search = new \Affilinet\ProductData\Requests\ProductsRequest($this->affilinetClient);
$result = $search->findOne('5495949');
$result = $search->findOne('843922757');

$this->assertInstanceOf(\Affilinet\ProductData\Responses\ResponseElements\Product::class, $result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class ShopPropertiesIntegrationTest extends \PHPUnit_Framework_TestCase
{
/**
* @var $affilinetClient \Affilinet\ProductData\AffilinetClient
* @var $affilinetClient \Affilinet\ProductData\AffilinetProductClient
*/
protected $affilinetClient;

Expand All @@ -26,11 +26,11 @@ protected function setUp()
$log = new \Monolog\Logger('testlog');
$log->pushHandler(new \Monolog\Handler\TestHandler());

$this->affilinetClient = new \Affilinet\ProductData\AffilinetClient(
$this->affilinetClient = new \Affilinet\ProductData\AffilinetProductClient(
[
'log' => $log,
'publisher_id' => \Affilinet\Tests\AffilinetTestCredentials::$publisherId,
'product_webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword,
'webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword,
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
class ShopsIntegrationTest extends \PHPUnit_Framework_TestCase
{

use VladaHejda\AssertException;

/**
* @var $affilinetClient \Affilinet\ProductData\AffilinetClient
* @var $affilinetClient \Affilinet\ProductData\AffilinetProductClient
*/
protected $affilinetClient;

Expand All @@ -29,11 +27,11 @@ protected function setUp()
$log = new \Monolog\Logger('testlog');
$log->pushHandler(new \Monolog\Handler\TestHandler());

$this->affilinetClient = new \Affilinet\ProductData\AffilinetClient(
$this->affilinetClient = new \Affilinet\ProductData\AffilinetProductClient(
[
'log' => $log,
'publisher_id' => \Affilinet\Tests\AffilinetTestCredentials::$publisherId,
'product_webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword,
'webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword,
]
);

Expand Down
44 changes: 22 additions & 22 deletions Tests/Unit/ProductData/AffilinetClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,59 @@ class AffilinetClientTest extends \PHPUnit_Framework_TestCase
{

/**
* @expectedException \Affilinet\ProductData\Exceptions\AffilinetProductWebserviceException
* @expectedException \Affilinet\Exceptions\AffilinetWebserviceException
*/
public function testConstructorThrowsIfNoConfig()
{
$affilinetClient = new \Affilinet\ProductData\AffilinetClient();
$affilinetClient = new \Affilinet\ProductData\AffilinetProductClient();

}

/**
* @expectedException \Affilinet\ProductData\Exceptions\AffilinetProductWebserviceException
* @expectedException \Affilinet\Exceptions\AffilinetWebserviceException
*/
public function testConstructorThrowsIfNoPublisherId()
{
$affilinetClient = new \Affilinet\ProductData\AffilinetClient(['product_webservice_password' => '123456789']);
$affilinetClient = new \Affilinet\ProductData\AffilinetProductClient(['webservice_password' => '123456789']);

}

/**
* @expectedException \Affilinet\ProductData\Exceptions\AffilinetProductWebserviceException
* @expectedException \Affilinet\Exceptions\AffilinetWebserviceException
*/
public function testConstructorThrowsIfNoProductWebservicePassword()
{
$affilinetClient = new \Affilinet\ProductData\AffilinetClient(['publisher_id' => '123']);
$affilinetClient = new \Affilinet\ProductData\AffilinetProductClient(['publisher_id' => '123']);
}

public function testConstructorUsesFallbackData()
{
$publisherIDVarName = \Affilinet\ProductData\AffilinetClient::PUBLISHER_ID_ENV_NAME;
$webservicePassVarName = \Affilinet\ProductData\AffilinetClient::PRODUCT_WEBSERVICE_PASSWORD_ENV_NAME;
$publisherIDVarName = \Affilinet\ProductData\AffilinetProductClient::PUBLISHER_ID_ENV_NAME;
$webservicePassVarName = \Affilinet\ProductData\AffilinetProductClient::WEBSERVICE_PASSWORD_ENV_NAME;
putenv("{$publisherIDVarName}=123");
putenv("{$webservicePassVarName}=123");
$affilinetClient = new \Affilinet\ProductData\AffilinetClient();
$affilinetClient = new \Affilinet\ProductData\AffilinetProductClient();
}

public function testGetterSetter()
{
$config = [
'product_webservice_password' => '123',
'webservice_password' => '123',
'publisher_id' => '123'
];
$affilinetClient = new \Affilinet\ProductData\AffilinetClient();
$this->assertEquals($config['product_webservice_password'], $affilinetClient->getProductDataWebservicePassword());
$affilinetClient = new \Affilinet\ProductData\AffilinetProductClient();
$this->assertEquals($config['webservice_password'], $affilinetClient->getWebservicePassword());
$this->assertEquals($config['publisher_id'], $affilinetClient->getPublisherId());
}

public function testHttpClientExists()
{
$config = [
'product_webservice_password' => '123',
'webservice_password' => '123',
'publisher_id' => '123'
];
$affilinetClient = new \Affilinet\ProductData\AffilinetClient($config);
$this->assertInstanceOf(\Affilinet\ProductData\HttpClient\HttpClientInterface::class, $affilinetClient->getHttpClient());
$affilinetClient = new \Affilinet\ProductData\AffilinetProductClient($config);
$this->assertInstanceOf(\Affilinet\HttpClient\HttpClientInterface::class, $affilinetClient->getHttpClient());
}

public function testUseExternalGuzzleClient()
Expand All @@ -79,11 +79,11 @@ public function testUseExternalGuzzleClient()
'timeout' => 2.0,
]);
$config = [
'product_webservice_password' => '123',
'webservice_password' => '123',
'publisher_id' => '123',
'http_client' => $client
];
new \Affilinet\ProductData\AffilinetClient($config);
new \Affilinet\ProductData\AffilinetProductClient($config);
}

public function testUsageOfExternalClientLibraryImplementingHttpClientInterface()
Expand All @@ -94,13 +94,13 @@ public function testUsageOfExternalClientLibraryImplementingHttpClientInterface(
// You can set any number of default request options.
'timeout' => 2.0,
]);
$http_client = new \Affilinet\ProductData\HttpClient\GuzzleClient($client);
$http_client = new \Affilinet\HttpClient\GuzzleClient($client);
$config = [
'product_webservice_password' => '123',
'webservice_password' => '123',
'publisher_id' => '123',
'http_client' => $http_client
];
new \Affilinet\ProductData\AffilinetClient($config);
new \Affilinet\ProductData\AffilinetProductClient($config);
}

/**
Expand All @@ -109,11 +109,11 @@ public function testUsageOfExternalClientLibraryImplementingHttpClientInterface(
public function testInvalidClientThrows()
{
$config = [
'product_webservice_password' => '123',
'webservice_password' => '123',
'publisher_id' => '123',
'http_client' => '123'
];
new \Affilinet\ProductData\AffilinetClient($config);
new \Affilinet\ProductData\AffilinetProductClient($config);
}

}
4 changes: 2 additions & 2 deletions Tests/Unit/ProductData/Requests/CategoriesRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ protected function setUp()
$log = new \Monolog\Logger('testlog');
$log->pushHandler(new \Monolog\Handler\TestHandler());

$this->affilinetClient = new \Affilinet\ProductData\AffilinetClient(
$this->affilinetClient = new \Affilinet\ProductData\AffilinetProductClient(
[
'log' => $log,
'publisher_id' => 'test',
'product_webservice_password' => 'test'
'webservice_password' => 'test'
]
);

Expand Down
16 changes: 8 additions & 8 deletions Tests/Unit/ProductData/Requests/ProductsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ protected function setUp()
$log = new \Monolog\Logger('testlog');
$log->pushHandler(new \Monolog\Handler\TestHandler());

$this->affilinetClient = new \Affilinet\ProductData\AffilinetClient(
$this->affilinetClient = new \Affilinet\ProductData\AffilinetProductClient(
[
'log' => $log,
'publisher_id' => \Affilinet\Tests\AffilinetTestCredentials::$publisherId,
'product_webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword
'webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword
]
);

Expand All @@ -42,7 +42,7 @@ public function testExcludeShopIds()
}

/**
* @expectedException \Affilinet\ProductData\Exceptions\AffilinetProductWebserviceException
* @expectedException \Affilinet\Exceptions\AffilinetProductWebserviceException
*/
public function testExcludeShopIdsCanNotBeUsedWithOnlyFromShopIds()
{
Expand Down Expand Up @@ -83,7 +83,7 @@ public function testOnlyFromShopIdsLogsWarningIfTooManyShopIds()
}

/**
* @expectedException \Affilinet\ProductData\Exceptions\AffilinetProductWebserviceException
* @expectedException \Affilinet\Exceptions\AffilinetProductWebserviceException
*/
public function testOnlyFromShopIdsCanNotBeUsedWithExcludeShopIds()
{
Expand Down Expand Up @@ -711,7 +711,7 @@ public function testOnlyFromShops()
public function testQueryBuilder()
{
$search = new \Affilinet\ProductData\Requests\ProductsRequest($this->affilinetClient);
$query = new \Affilinet\ProductData\Requests\Helper\Query();
$query = new \Affilinet\Requests\Helper\Query();

$search->query(
$query->where(
Expand All @@ -728,7 +728,7 @@ public function testQueryBuilder()
public function testQueryBuilderWhere()
{
$search = new \Affilinet\ProductData\Requests\ProductsRequest($this->affilinetClient);
$query = new \Affilinet\ProductData\Requests\Helper\Query();
$query = new \Affilinet\Requests\Helper\Query();

$search->query(
$query
Expand All @@ -743,7 +743,7 @@ public function testQueryBuilderWhere()
public function testQueryBuilderContains()
{
$search = new \Affilinet\ProductData\Requests\ProductsRequest($this->affilinetClient);
$query = new \Affilinet\ProductData\Requests\Helper\Query();
$query = new \Affilinet\Requests\Helper\Query();

$search->query(
$query
Expand All @@ -758,7 +758,7 @@ public function testQueryBuilderContains()
}

/**
* @expectedException \Affilinet\ProductData\Exceptions\AffilinetProductWebserviceException
* @expectedException \Affilinet\Exceptions\AffilinetProductWebserviceException
*/
public function testProductRequestMustNotBeEmpty()
{
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/ProductData/Requests/ShopPropertiesRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ protected function setUp()
$log = new \Monolog\Logger('testlog');
$log->pushHandler(new \Monolog\Handler\TestHandler());

$this->affilinetClient = new \Affilinet\ProductData\AffilinetClient(
$this->affilinetClient = new \Affilinet\ProductData\AffilinetProductClient(
[
'log' => $log,
'publisher_id' => 'test',
'product_webservice_password' => 'test'
'webservice_password' => 'test'
]
);

Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/ProductData/Requests/ShopsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ protected function setUp()
$log = new \Monolog\Logger('testlog');
$log->pushHandler(new \Monolog\Handler\TestHandler());

$this->affilinetClient = new \Affilinet\ProductData\AffilinetClient(
$this->affilinetClient = new \Affilinet\ProductData\AffilinetProductClient(
[
'log' => $log,
'publisher_id' => \Affilinet\Tests\AffilinetTestCredentials::$publisherId,
'product_webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword
'webservice_password' => \Affilinet\Tests\AffilinetTestCredentials::$productWebservicePassword
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function testDateParseAcceptsDate()
date_default_timezone_set("Europe/Berlin");

$dateString = '/Date(1468928770807+0200)/';
$dateTime = \Affilinet\ProductData\Responses\DataParser::parseDate($dateString);
$dateTime = \Affilinet\Responses\DataParser::parseDate($dateString);
$this->assertEquals('7200', $dateTime->getOffset());
$this->assertEquals(new DateTimeZone('+02:00'), $dateTime->getTimezone());
$this->assertEquals('1468921570', $dateTime->getTimestamp());
Expand All @@ -31,7 +31,7 @@ public function testDateParseAcceptsDate()
public function testInvalidStringThrowsUnexpectedValueException()
{
$dateString = 'i am not a correct js time object';
$dateTime = \Affilinet\ProductData\Responses\DataParser::parseDate($dateString);
$dateTime = \Affilinet\Responses\DataParser::parseDate($dateString);
}

}
Loading