Skip to content

Improve tests, replace psr7 implementation #152

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

Merged
merged 1 commit into from
Jan 21, 2019

Conversation

acasademont
Copy link
Contributor

Trying to add tests for #144 proved to be quite complicated if we don't have a full Symfony kernel for the tests. Therefore, I've refactored all the current tests to stop using mocks and use a real Symfony kernel/controllers...

As a side effect, the current PSR-7 library did not support the UploadFileInterface and replace it with Guzzle (which is better maintained by the way).

This is just the first step in all the planned refactors :)

"symfony/http-foundation": "^2.6|^3.0|^4",
"symfony/http-kernel": "^2.6|^3.0|^4",
"ringcentral/psr7": "^1.2"
"symfony/http-foundation": "^3.4|^4",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dropped 2.X already

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think- can we release this in a point release? Effectively we're dropping support for Symfony before 3.4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The proposed 'kernel.reset' interface for Symfony is only in 3.4+. Also, SF 2.x is EOL already, I'd say it's time to move on.

@andig
Copy link
Contributor

andig commented Jan 19, 2019

Wow, this is huge! Will need some time to check, sorry.

@acasademont
Copy link
Contributor Author

No worries, happy to help! The test assertions haven't changed, seems big but I don't think is thaaat big :p

@@ -1,87 +0,0 @@
<?php
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andig basically I copied all the code in the previous Kernel mock and put it inside the newly created controllers, that allows us to keep the assertions the same


namespace PHPPM\Tests\Fixtures;

class ProcessSlaveDouble
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used to have support for the register_file function without having a real Slave

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will be useful when creating a test that checks if a symfony container resource is actually being added to the list of watched files

@@ -9,7 +9,7 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UploadedFileInterface;
use RingCentral\Psr7;
use GuzzleHttp\Psr7;
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that's not really needed here but it reduces the number of dependencies?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a change to a more complete PSR7 implementation and to a better maintained library, it doesn't really change the number of dependencies itself.

Also, the Psr7 Response object is used here. Are you refering to something else?

"symfony/http-foundation": "^2.6|^3.0|^4",
"symfony/http-kernel": "^2.6|^3.0|^4",
"ringcentral/psr7": "^1.2"
"symfony/http-foundation": "^3.4|^4",
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think- can we release this in a point release? Effectively we're dropping support for Symfony before 3.4?

"phpunit/phpunit": "^5.7"
"phpunit/phpunit": "^5.7",
"symfony/framework-bundle": "^3.4|^4",
"doctrine/annotations": "^1.6"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to require the annotations here or aren't they implicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nopes, they aren't implicit, Symfony relies on them for routing annotation but you need to import the library yourself

@andig
Copy link
Contributor

andig commented Jan 21, 2019

As for symfony bundle: is it a good idea to require them in the composer json? That way we will only ever be able to install a single framework instead of testing them separately. Wondering if it would make more sense to move the symfony framework to travis.yml to prepare a separate environment per framework.

Apart from that LGTM.

@acasademont
Copy link
Contributor Author

As for symfony bundle: is it a good idea to require them in the composer json? That way we will only ever be able to install a single framework instead of testing them separately. Wondering if it would make more sense to move the symfony framework to travis.yml to prepare a separate environment per framework.

It's a good question! The three frameworks can live together without a problem, we're already doing that for phpstan in travis (we install Laravel, Symfony and Drupal). I'm not a Laravel or Drupal expert but I don't see why testing them should interfere with Symfony.

Also, I'm not a fan of moving too much logic into Travis, imo tests should be runnable with a simple "phpunit" command.

@andig
Copy link
Contributor

andig commented Jan 21, 2019

Then I would propose to merge as-is and then proceed with #144

@acasademont
Copy link
Contributor Author

@andig sounds good to me! I will submit another PR before #144 that adds new tests for all the hacks we have in place and then check if the tests still pass after the refactor.

@andig andig merged commit 6210935 into php-pm:master Jan 21, 2019
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.

2 participants