Skip to content

Conversation

@Doodoune
Copy link
Contributor

Replace all integration tests by end-to-end tests using "donatj/mock-webserver".

@Doodoune Doodoune force-pushed the API-599 branch 7 times, most recently from ac2c5d5 to 0621a09 Compare May 17, 2018 10:01
language: php

php:
- 7.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5.6
7.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

/**
* @return StreamFactory
*/
protected function getStreamFactory()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is it used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In UpsertListProductTest sur le test test_upsert_list_from_stream

Copy link
Collaborator

@ahocquard ahocquard May 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed to share with every tests in this case.
And if it's function shared across several test, it's a good candidate about using a trait.

'locale' => null,
]);

$this->assertSame('f/b/0/6/fb068ccc9e3c5609d73c28d852812ba5faeeab28_akeneo.png', $response);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert::assertSame

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check in the history of the response stack (take a look at the library documentation) what if the body of the request what what we expects.
For now, you are just checking the URI call.

$api = $this->createClient()->getProductApi();
$response = $api->create('new_shoes', $this->newProduct());

$this->assertSame(201, $response);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same (almost evrywhere): check the body of the request. You can do a function in ApiTestCase.

$api = $this->createClient()->getProductApi();
$firstPage = $api->listPerPage(10, true, []);

$this->assertInstanceOf(PageInterface::class, $firstPage);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert::

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed everywere

@Doodoune Doodoune force-pushed the API-599 branch 7 times, most recently from 20ef38e to 579ced8 Compare May 18, 2018 08:39
@ahocquard ahocquard force-pushed the API-599 branch 3 times, most recently from 9061ee0 to 6221347 Compare May 18, 2018 09:58
@Doodoune Doodoune force-pushed the API-599 branch 3 times, most recently from 5b31354 to b2083d4 Compare May 18, 2018 12:17
@Doodoune Doodoune force-pushed the API-599 branch 3 times, most recently from 0b85c57 to 5d3cba1 Compare May 18, 2018 12:25
@ahocquard ahocquard force-pushed the API-599 branch 2 times, most recently from 1ac139f to cf0b8cb Compare May 18, 2018 12:34
@Doodoune Doodoune force-pushed the API-599 branch 3 times, most recently from 7755bcc to e5b639e Compare May 18, 2018 15:26
@Doodoune Doodoune force-pushed the API-599 branch 3 times, most recently from 74d9d02 to 1aacf98 Compare May 22, 2018 13:02
composer.json Outdated
"php-http/multipart-stream-builder": "^1.0",
"php-http/client-implementation": "^1.0"
"php-http/client-implementation": "^1.0",
"php-http/guzzle6-adapter": "^1.1"
Copy link
Contributor

@LaurentPetard LaurentPetard May 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both in "require" and "require-dev" ? I think it shouldn't be in "require"

@Doodoune Doodoune force-pushed the API-599 branch 3 times, most recently from 2dc0d86 to 97cca32 Compare May 22, 2018 15:48
@Doodoune
Copy link
Contributor Author

@LaurentPetard I remove both, we add it by composer require in the doc so I don't have to add it in composer.json

$response = $api->create($mediaFile, $productInfos);

Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_POST]['product'], json_encode($productInfos));
Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_REQUEST_URI], '/'. ProductMediaFileApi::MEDIA_FILES_URI);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless line

phpunit.xml.dist Outdated
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
processIsolation="false"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can keep it at true (maybe my commit which did that)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I change that

const LOWER_THAN_ON_ALL_LOCALES = 'LOWER THAN ON ALL LOCALES';
const LOWER_OR_EQUALS_THAN_ON_ALL_LOCALES = 'LOWER OR EQUALS THAN ON ALL LOCALES';
const EMPTY = 'EMPTY';
const IS_EMPTY = 'EMPTY';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is a BC

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the end, we will have to change it because it is not supported by php 5.6.... it's a kind of bug

$api = $this->createClient()->getProductApi();
$response = $api->create('new_shoes', $this->newProduct());

Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_INPUT], json_encode(array_merge($this->newProduct(), ["identifier" => "new_shoes"])));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of it.

You are doing logic inside your test by doing array_merge. Avoid that.
Put directly what you are expecting. Copy past in test is not a problem.

(it means that the function newProduct is usless)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{
public function test_download_media_file()
{
$expectedMediaFile = realpath(__DIR__ . '/../fixtures/akeneo.png');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FilePath, FIle is for generally for a ressource

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Assert::assertSame($this->server->getServerRoot() . '/api/rest/v1/products?page=2&with_count=true&pagination_type=page&limit=10', $firstPage->getNextLink());
Assert::assertEquals(count($firstPage->getItems()), 10);

$secondPage = $firstPage->getNextPage();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert the last request for the query parametesrs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already present a few line before : Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_GET], ['limit' => '10', 'with_count' => 'true']);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but nextPage does another new request. It's a cursor under the hood. So you have to check that this new call is done with good query parameters

@ahocquard
Copy link
Collaborator

ahocquard commented May 22, 2018

Almost GTM: please revert the BC break

@Doodoune Doodoune force-pushed the API-599 branch 3 times, most recently from 6f14728 to 0e4cf53 Compare May 23, 2018 07:30
@Doodoune Doodoune force-pushed the API-599 branch 2 times, most recently from 2f39841 to e2fcf8f Compare May 23, 2018 07:51
const LOWER_THAN_ON_ALL_LOCALES = 'LOWER THAN ON ALL LOCALES';
const LOWER_OR_EQUALS_THAN_ON_ALL_LOCALES = 'LOWER OR EQUALS THAN ON ALL LOCALES';
const EMPTY = 'EMPTY';
const IS_EMPTY = 'EMPTY';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the end, we will have to change it because it is not supported by php 5.6.... it's a kind of bug

@Doodoune Doodoune merged commit 44ed422 into 1.0 May 23, 2018
@Doodoune Doodoune deleted the API-599 branch May 23, 2018 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants