Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 0152cf0

Browse files
author
ct-jensschulze
committed
Merge pull request #46 from sphereio/develop
1.0.0 Milestone 2
2 parents 29e237b + dad0f6e commit 0152cf0

File tree

471 files changed

+8451
-1676
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

471 files changed

+8451
-1676
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
vendor
44
build
55
cache.properties
6+
apigen.phar
67
composer.phar
78
composer.lock
89
docroot/myapp.ini

.scrutinizer.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,14 @@ build:
1717
- if [[ "`phpenv version-name`" =~ "^5.4" ]] && [ "`phpenv version-name`" != "hhvm" ]; then echo -e "apc.enabled=1\napc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
1818
#+5.5 uses APCU
1919
- if [[ ! "`phpenv version-name`" =~ "^5.4" ]] && [ "`phpenv version-name`" != "hhvm" ]; then printf "\n"| echo -e "apc.enabled=1\napc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
20+
tests:
21+
override:
22+
-
23+
command: vendor/bin/behat -f progress
24+
-
25+
command: vendor/bin/phpunit --testsuite=unit --coverage-clover=coverage0
26+
coverage:
27+
file: 'coverage0'
28+
format: 'php-clover'
2029
filter:
2130
excluded_paths: [build/*, tests/*, docroot/*, features/*]

.travis.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@ cache:
1616
- vendor
1717

1818
before_script:
19-
- sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ] && [ `php-config --vernum` -ge 50500 ] ; then pecl config-set preferred_state beta; printf "yes\n" | pecl install -f apcu ; else echo 'extension="apc.so"' >> ./tests/apc.ini ; fi"
20-
- sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ]; then phpenv config-add ./tests/apc.ini; fi"
21-
- if [ $(phpenv version-name) = '5.4' ]; then PHPUNIT_FLAGS="--coverage-clover=coverage.clover"; else PHPUNIT_FLAGS=""; fi
22-
- composer self-update
19+
- sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ] && [ $TRAVIS_PHP_VERSION != 'nightly' ] && [ `php-config --vernum` -ge 50500 ] ; then pecl config-set preferred_state beta; printf "yes\n" | pecl install -f apcu ; else echo 'extension="apc.so"' >> ./tests/apc.ini ; fi"
20+
- sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ] && [ $TRAVIS_PHP_VERSION != 'nightly' ] ; then phpenv config-add ./tests/apc.ini; fi"
2321
- composer install --prefer-source -o
2422

2523
script:
2624
- ant phpcs-ci
27-
- phpunit $PHPUNIT_FLAGS
25+
- phpunit --testsuite=unit
26+
- if [ $TRAVIS_PHP_VERSION == '5.4' ] ; then phpunit --testsuite=integration; fi
2827
- ant behat
29-
- if [ $TRAVIS_PHP_VERSION != 'hhvm' ] && [ $(phpenv version-name) = '5.4' ]; then ant apigen; fi
3028

3129
after_success:
3230
- ./push-docs-to-gh-pages.sh
@@ -35,3 +33,9 @@ env:
3533
global:
3634
# GH_TOKEN environment variable for pushing documentation:
3735
- secure: "i0TL7GsZ8TIZgr7WB5qXEs8fF5sSJHGagLXEsn4DSgxI52GatfjeEaSJuAbbWV/Tg0jYidNevdhCpe7LT3IWwa2cLVRpaV1TDoQ6K4wo8zzMzAw4AMB8DO2dBY3Mz+puRN55YAV3OpEF/RiiIc7zXLW/+5H9UCOXrcnnpg6PpxE="
36+
# SPHERE_CLIENT_ID
37+
- secure: MEht7kleJ/K9/daNOjEpPNJnXxKyQZ36oEM8fImi612BoJmZp/uwjuKpqKscIyyLwXSpsr7c9w+V2CfSk3QI+NGLnhSNgjJWE2QXxzxD6OgM0gKFTDtBq//+k77Sx4UnQDi0pQPRZ1BrfBUqrxw4H07i53hXd/kmjZnknRcbODc=
38+
# SPHERE_CLIENT_SECRET
39+
- secure: Q4zRyFxLw/7YlHG/iWzyR7V7Srm8LsQ3UgMshckUyqefhzhF19GefoPJdPdALyLVEYQMG3O/U1aebbyt8Puy5jWWKKiwFaQA+mMXzpBFcvhutgxByqBXdIysIhGU65No+WbiCKlpL2WPNtYvE1cMSjFfn7IX8ThGkBxhJQcha38=
40+
# SPHERE_PROJECT
41+
- secure: CPj46vCtmLaxGKXycJW+PmNXloXu5ruOV/Qg1mA6tU83oPjlxHVrqMOlb87ykf6U8X6XXAjMrgR0q3gBepPJg3HZmJyeOsVhwSU/jhfN7L1lR7BrQrPdLutvhuC6Fgj+b2Ubzh7PIt7pR6AYZyMCv5ofajW9aBcC5D556WJsSjE=

CHANGELOG.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,51 @@
11
# SPHERE.IO PHP SDK Changelog
22

3+
### 1.0.0 Milestone 2
4+
* add unit tests for query, fetch and delete requests
5+
* add tests for order and product update actions
6+
* add customer, category and cart update action tests
7+
* refactor annotation generator
8+
* refactor context aware objects to give a context callback to child
9+
* add constructor tests for update commands
10+
* add customer object and order create request test
11+
* add customer request tests
12+
* update Collection and JsonObject tests
13+
* add model unit tests
14+
* execute apigen only at master or tag changes
15+
* fix state and taxRate
16+
* add reference test
17+
* add typed objects for references
18+
* add currency formatter test
19+
* refactor collection and jsonObject
20+
* remove deprecated functions
21+
* add integration tests for category
22+
* refactor query parameters
23+
* add reference getter to JsonObject
24+
* return references only for documents
25+
* log deprecation headers
26+
* add pool size configuration to client
27+
* add future requests
28+
* add future tests
29+
* add toString to LocalizedSearchKeywords model
30+
* fix product draft tax category
31+
* add links to api documentation for models
32+
* correct type hints for zone requests
33+
* add links to api documentation for requests
34+
* add limit of update action logging to update requests
35+
* add cache adapter for redis storage
336

37+
### 1.0.0 Milestone 1
38+
* batch execution of requests
39+
* delete, update, fetchById and query requests for all endpoints
40+
* cart create and update requests
41+
* cart update actions
42+
* order create and update requests
43+
* order update actions
44+
* customer create and update requests
45+
* customer update actions
46+
* customer sign-in, email verification and password requests
47+
* custom object create request
48+
* api result to object mapping
449

5-
### 1.0.0-M0
6-
* initial commit
50+
### 1.0.0 Milestone 0
51+
* initial commit

README.md

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
> WARNING: As of now, this is a pre-release partial implementation.
55
> See the [Milestone Plan](https://github.com/sphereio/sphere-php-sdk/milestones?direction=desc&sort=completeness&state=open) for details of what's planned. We love feedback and [Issue reports](https://github.com/sphereio/sphere-php-sdk/issues?q=is%3Aopen+is%3Aissue+sort%3Acreated-asc)!
66
7-
[![Build Status](https://img.shields.io/travis/sphereio/sphere-php-sdk/develop.svg?style=flat-square)](https://travis-ci.org/sphereio/sphere-php-sdk) [![Scrutinizer](https://img.shields.io/scrutinizer/g/sphereio/sphere-php-sdk.svg?style=flat-square)](https://scrutinizer-ci.com/g/sphereio/sphere-php-sdk/) [![Scrutinizer](https://img.shields.io/scrutinizer/coverage/g/sphereio/sphere-php-sdk.svg?style=flat-square)](https://scrutinizer-ci.com/g/sphereio/sphere-php-sdk/) [![Packagist](https://img.shields.io/packagist/v/sphere/php-sdk.svg?style=flat-square)](https://packagist.org/packages/sphere/php-sdk) [![Packagist](https://img.shields.io/packagist/dm/sphere/php-sdk.svg?style=flat-square)](https://packagist.org/packages/sphere/php-sdk)
8-
9-
The PHP SDK allows developers to build applications on the SPHERE.IO REST API using PHP native interfaces, models and helpers instead of manually using the HTTP and JSON API. Users gain lots of IDE Auto-Completion and type checks on a literal API.
10-
It also manages the OAuth2 security, provides caches and an interface for concurrent and asynchronous API calls.
7+
[![Build Status](https://img.shields.io/travis/sphereio/sphere-php-sdk/master.svg?style=flat-square)](https://travis-ci.org/sphereio/sphere-php-sdk) [![Scrutinizer](https://img.shields.io/scrutinizer/g/sphereio/sphere-php-sdk.svg?style=flat-square)](https://scrutinizer-ci.com/g/sphereio/sphere-php-sdk/) [![Scrutinizer](https://img.shields.io/scrutinizer/coverage/g/sphereio/sphere-php-sdk.svg?style=flat-square)](https://scrutinizer-ci.com/g/sphereio/sphere-php-sdk/) [![Packagist](https://img.shields.io/packagist/v/sphere/php-sdk.svg?style=flat-square)](https://packagist.org/packages/sphere/php-sdk) [![Packagist](https://img.shields.io/packagist/dm/sphere/php-sdk.svg?style=flat-square)](https://packagist.org/packages/sphere/php-sdk)
8+
9+
The PHP SDK allows developers to build applications on the SPHERE.IO REST API using PHP native interfaces, models and helpers instead of manually using the HTTP and JSON API. Users gain lots of IDE Auto-Completion and type checks on a literal API.
10+
It also manages the OAuth2 security, provides caches and an interface for concurrent and asynchronous API calls.
1111

1212
The SDK is licensed under the permissive [MIT License](LICENSE). Don't hesitate to [contribute](#contribute)!
1313

1414
## Install / Integrate into your Project
1515

16-
The SDK requires a PHP version of 5.4 or higher with the apc(u) PHP extension for its default cache. If you provide an own Cache interface, apc(u) is not necessary. The curl extension is recommended but not strictly necessary because the SDK is using the [Guzzle library](https://github.com/guzzle/guzzle) library, which falls back to PHP stream wrappers if curl is not available.
16+
The SDK requires a PHP version of 5.4 or higher with the apc(u) PHP extension for its default cache. If you provide an own Cache interface, apc(u) is not necessary. The curl extension is recommended but not strictly necessary because the SDK is using the [Guzzle library](https://github.com/guzzle/guzzle) library, which falls back to PHP stream wrappers if curl is not available.
1717

1818
The recommended way to install the SDK is through [Composer](http://getcomposer.org).
1919

@@ -34,23 +34,29 @@ After installing, you need to require Composer's autoloader if that's not yet th
3434
require 'vendor/autoload.php';
3535
```
3636

37-
If you don't use Composer, just [download a zip archive](archive/master.zip) of the latest release, manually integrate it and configure your own autoloader.
37+
If you don't use Composer, just [download a zip archive](archive/master.zip) of the latest release, manually integrate it and configure your own autoloader.
3838

39-
Until the 1.0.0 release M0, M1 etc. milestone releases can contain incompatible changes. From 1.0.0 on, the project will follow the [semantic versioning](http://semver.org) guidelines, i.e. everything but major version changes are backwards-compatible. This matches composer's default behavior.
39+
Until the 1.0.0 release M0, M1 etc. milestone releases can contain incompatible changes. From 1.0.0 on, the project will follow the [semantic versioning](http://semver.org) guidelines, i.e. everything but major version changes are backwards-compatible. This matches composer's default behavior.
4040

41-
With composer just run `composer update sphere/php-sdk` to update to compatible versions. Edit your `composer.json` file to update to incompatible versions.
41+
With composer just run `composer update sphere/php-sdk` to update to compatible versions. Edit your `composer.json` file to update to incompatible versions.
4242

43-
Please read the [Changelog](CHANGELOG.md) before updating in any case.
43+
Please read the [Changelog](CHANGELOG.md) before updating in any case.
4444

4545
## Use the SDK
4646

47-
To get up and running, [create a free test project](http://admin.sphere.io) to get a SPHERE project with API credentials (Menu "Developers"->"API Clients").
47+
To get up and running, [create a free test project](http://admin.sphere.io) to get a SPHERE project with API credentials (Menu "Developers"->"API Clients").
4848

4949
```php
5050
<?php
51+
52+
require '../vendor/autoload.php';
53+
54+
use Sphere\Core\Request\Products\ProductsSearchRequest;
55+
use Sphere\Core\Client;
56+
57+
header('Content-Type: text/html; charset=utf-8');
58+
5159
$config = [
52-
'oauth_url' => 'https://auth.sphere.io/oauth/token',
53-
'api_url' => 'https://api.sphere.io',
5460
'client_id' => 'my client id',
5561
'client_secret' => 'my client secret',
5662
'project' => 'my project id'
@@ -59,26 +65,25 @@ $config = [
5965
/**
6066
* create search request
6167
*/
62-
$search = new \Sphere\Core\Request\Products\ProductsSearchRequest();
63-
$search->addParam('text.en', 'red');
68+
$search = ProductsSearchRequest::of()->addParam('text.en', 'red');
6469

65-
$client = new \Sphere\Core\Client($config);
66-
$results = $client->execute($search);
70+
$client = new Client($config);
71+
$products = $client->execute($search)->toObject();
6772

68-
foreach($results as $result) {
69-
var_dump($result);
73+
foreach ($products as $product) {
74+
echo $product->getName()->en . '<br/>';
7075
}
7176

7277
?>
7378
```
7479

75-
In real world, you will not put your API credentials directly into code but use a config file or your framework's config or dependency injection system for that.
80+
In real world, you will not put your API credentials directly into code but use a config file or your framework's config or dependency injection system for that.
7681

77-
The [API documentation](http://sphereio.github.io/sphere-php-sdk/docs/master) provides all the details you need in a searchable form.
82+
The [API documentation](http://sphereio.github.io/sphere-php-sdk/docs/master) provides all the details you need in a searchable form.
7883

7984
## Develop and Improve
8085

81-
prepare your development environment (if necessary).
86+
prepare your development environment (if necessary).
8287

8388
Mac OS X, assuming [Homebrew](http://brew.sh) is installed, do the following:
8489

@@ -97,15 +102,15 @@ echo "date.timezone='Europe/Berlin'" >> /usr/local/etc/php/5.5/conf.d/60-user.in
97102
php composer.phar update
98103
```
99104

100-
Linux users install php 5.4+, apc(u), xdebug and ant according to their distro's package system.
105+
Linux users install php 5.4+, apc(u), xdebug and ant according to their distro's package system.
101106

102107
Clone the develop branch of the repository (we're using the [gitflow](http://nvie.com/posts/a-successful-git-branching-model/) branching model, so master is for releases only):
103108

104109
```
105110
git clone git@github.com:sphereio/sphere-php-sdk.git
106111
```
107112

108-
Please follow the [PSR-2](http://www.php-fig.org/psr/psr-2/) coding style, ideally via your IDE settings (see below for phpStorm instructions).
113+
Please follow the [PSR-2](http://www.php-fig.org/psr/psr-2/) coding style, ideally via your IDE settings (see below for phpStorm instructions).
109114

110115
Please make sure that exiting Unit and Integration tests don't fail and fully cover your new code with Unit Tests. You can run all tests locally:
111116

@@ -119,14 +124,12 @@ You can use the `docroot` directory with the built-in PHP web server. Add to the
119124

120125
```ini
121126
[sphere]
122-
oauth_url = 'https://auth.sphere.io/oauth/token'
123-
api_url = 'https://api.sphere.io'
124127
client_id = 'my client id'
125128
client_secret = 'my client secret'
126129
project = 'my project id'
127130
```
128131

129-
Then activate the php builtin web server
132+
Then activate the php builtin web server
130133

131134
```sh
132135
cd <project_folder>
@@ -143,14 +146,14 @@ Now you can enable at Preferences > Editor > Inspections > PHP the "PHP code sni
143146

144147
## <a name="contribute"></a>Contribute
145148

146-
On bigger effort changes, please open a GitHub [issue](issues) and ask if you can help or get help with your idea. For typos and documentation improvements just make a pull request.
149+
On bigger effort changes, please open a GitHub [issue](issues) and ask if you can help or get help with your idea. For typos and documentation improvements just make a pull request.
147150

148151
Then:
149152

150153
1. fork the repository on GitHub
151154
2. code and add tests that cover the created code. Your code should be warning-free.
152-
3. stick to PSR-2 and and don't reformat existing code.
153-
4. make a pull request. @ct-jensschulze will review it and pull or come back to you.
155+
3. stick to PSR-2 and and don't reformat existing code.
156+
4. make a pull request. @ct-jensschulze will review it and pull or come back to you.
154157

155158

156159

behat.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
default:
2+
suites:
3+
request_features:
4+
paths: [ %paths.base%/features/request ]

build.xml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,38 @@
171171
</exec>
172172
</target>
173173

174-
<target name="phpunit"
174+
<target name="phpunit" description="Run tests with PHPUnit"
175+
depends="unit-test, integration-test">
176+
</target>
177+
178+
<target name="unit-test"
175179
depends="prepare"
176180
description="Run unit tests with PHPUnit">
177181
<exec executable="${toolsdir}phpunit" failonerror="true">
178182
<arg value="--configuration"/>
179183
<arg path="${basedir}/phpunit.xml.dist"/>
184+
<arg value="--testsuite=unit"/>
185+
</exec>
186+
</target>
187+
188+
<target name="integration-test"
189+
depends="prepare"
190+
description="Run integration tests with PHPUnit">
191+
<exec executable="${toolsdir}phpunit" failonerror="true">
192+
<arg value="--configuration"/>
193+
<arg path="${basedir}/phpunit.xml.dist"/>
194+
<arg value="--testsuite=integration"/>
180195
</exec>
181196
</target>
182197

198+
<target name="install-apigen">
199+
<exec executable="${basedir}/apigen.sh" dir="${basedir}" />
200+
</target>
183201
<target name="apigen"
184202
depends="prepare"
185203
description="Generate project documentation using phpDocumentor">
186-
<exec executable="${basedir}/${toolsdir}apigen" dir="${basedir}/build/" failonerror="true">
204+
<exec executable="php" dir="${basedir}/build/" failonerror="true">
205+
<arg value="${basedir}/vendor/bin/apigen"/>
187206
<arg value="generate"/>
188207
<arg value="--source"/>
189208
<arg path="${basedir}/src"/>

composer.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,31 @@
88
},
99
"autoload-dev": {
1010
"psr-4": {
11-
"Sphere\\Core\\": "tests/unit/"
11+
"Sphere\\Core\\": [
12+
"tests/unit/",
13+
"tests/integration/"
14+
]
1215
}
1316
},
1417
"require": {
1518
"php": ">=5.4",
19+
"psr/log": "~1.0",
1620
"guzzlehttp/guzzle": "~5.0",
17-
"guzzlehttp/log-subscriber": "~1.0"
21+
"guzzlehttp/log-subscriber": "~1.0",
22+
"pimple/pimple": "~3.0"
1823
},
1924
"require-dev": {
20-
"psr/log": "~1.0",
2125
"phpunit/phpunit": "~4.0",
2226
"phpmd/phpmd": "~1.0",
2327
"squizlabs/php_codesniffer": "~1.0",
24-
"pdepend/pdepend": "1.1.*",
25-
"phploc/phploc": "2.0.*",
26-
"sebastian/phpcpd": "1.4.*",
27-
"covex-nn/phpcb": "1.0.4.*",
28+
"pdepend/pdepend": "~1.1",
29+
"phploc/phploc": "~2.0",
30+
"sebastian/phpcpd": "~1.4",
31+
"mayflower/php-codebrowser": "~1.0",
2832
"doctrine/cache": "~1.4",
29-
"apigen/apigen": "~4.0",
3033
"monolog/monolog": "~1.12",
3134
"behat/behat": "~3.0",
35+
"apigen/apigen": "~4.1",
3236
"phpunit/phpcov": "*"
3337
},
3438
"suggest": {

docroot/annotations.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* @author @ct-jensschulze <jens.schulze@commercetools.de>
4+
*/
5+
6+
namespace Sphere\Core;
7+
8+
use Sphere\Core\Helper\Annotate\AnnotationGenerator;
9+
10+
require '../vendor/autoload.php';
11+
12+
$path = __DIR__ . '/../src/';
13+
14+
$generator = new AnnotationGenerator();
15+
$generator->run($path);

0 commit comments

Comments
 (0)