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

Align project settings with the other repositories #537

Merged
merged 10 commits into from Aug 25, 2017

Conversation

lcobucci
Copy link
Member

@lcobucci lcobucci commented Aug 1, 2017

Requiring PHP 7.1+, dropping HHVM and simplifying some stuff on the test suite.

@lcobucci lcobucci added this to the 1.6 milestone Aug 1, 2017
@lcobucci lcobucci self-assigned this Aug 1, 2017
@lcobucci lcobucci force-pushed the align-project-settings branch 2 times, most recently from 4a886b9 to 1fa9490 Compare August 1, 2017 23:07
* @param InputInterface $input
* @param OutputInterface $output
* @return mixed
*/
protected function askConfirmation($question, InputInterface $input, OutputInterface $output)
protected function askConfirmation(string $question, InputInterface $input, OutputInterface $output)
Copy link
Member

Choose a reason for hiding this comment

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

Technically, this is a BC break - people might have overridden this method to add their own logic.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, will remove the type declaration.

->write($sql, $direction);
}

protected function createSqlFileWriter(string $path): SqlFileWriter
Copy link
Member

Choose a reason for hiding this comment

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

private plz

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't... and it really hurts me.
We were using mockery a big nasty black magic to overload the instantiation of that class. I didn't wan't to do a huge design change to make it work properly with only PHPUnit mocks.

Suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

Got a link to the test? :-\

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@lcobucci urgh. I am really reluctant to introduce a new protected method that will be abused till eternity :S

A huge test change would be more acceptable than this, IMO...

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I'll go down the rabbit hole on this one. However it would probably not be only a test change.

->write($sqlQueries, $direction);
}

protected function createSqlFileWriter(string $path): SqlFileWriter
Copy link
Member

Choose a reason for hiding this comment

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

Unless designed for inheritance, private

Copy link
Member Author

Choose a reason for hiding this comment

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

Same reason as #537 (comment)

Copy link
Contributor

@mikeSimonson mikeSimonson left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.
Great update.

composer.json Outdated
"doctrine/coding-standard": "dev-master",
"mockery/mockery": "^0.9.4",
"johnkary/phpunit-speedtrap": "~1.0@dev",
Copy link
Contributor

Choose a reason for hiding this comment

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

@lcobucci Why are you removing speedtrap ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the stable version doesn't support PHPUnit 6. Also I don't see much value on it right now, the only reason we had slow tests on the suite was the fact we were using mockery overload instance feature and that require tests to run in isolated processes, which has been removed.

I can add it back though 😄

if (!$this->getHelperSet()->has('question')) {
return $this->getHelper('dialog')->askConfirmation($output, '<question>' . $question . '</question>', false);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

There are tests that are tied to this BC feature that you can remove too.

Copy link
Member Author

@lcobucci lcobucci Aug 2, 2017

Choose a reason for hiding this comment

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

Our coverage report said we weren't covering this flow, can you point out the test to me?

Copy link
Contributor

Choose a reason for hiding this comment

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

public function testAskConfirmation()
{
$input = $this->getMockBuilder(ArrayInput::class)
->setConstructorArgs([[]])
->setMethods(['getOption'])
->getMock();
/**
* This test is testing a deprecated method.
* PHPunit convert those deprecations errors into tests failures.
* You can either use \PHPUnit_Framework_Error_Deprecated::$enabled = false;
* or use the @ operator to suppress the error.
* The advantage of the later is that it also remove the error message from the phpunit output.
*/
if (class_exists("Symfony\\Component\\Console\\Helper\\DialogHelper"))
{
@$helper = new DialogHelper();
@$this->assertTrue($this->invokeAbstractCommandConfirmation($input, $helper));
@$this->assertFalse($this->invokeAbstractCommandConfirmation($input, $helper, "n"));
}
if (class_exists("Symfony\\Component\\Console\\Helper\\QuestionHelper")) {
$helper = new QuestionHelper();
$this->assertTrue($this->invokeAbstractCommandConfirmation($input, $helper));
$this->assertFalse($this->invokeAbstractCommandConfirmation($input, $helper, "n"));
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 😉

.travis.yml Outdated
@@ -42,5 +42,4 @@ before_install:
- if [[ ! $GITHUB_TOKEN ]]; then echo "no github token"; fi

after_script:
- if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then php vendor/bin/coveralls -v ; fi
Copy link
Contributor

Choose a reason for hiding this comment

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

I am still using it. Is it a problem to keep it ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not a big problem to keep it, I just saw on https://coveralls.io/github/doctrine/migrations that the last build was March 2015 so I assumed it was useless here as well

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you sure we're using for doctrine/migrations? Do you want me to put it back?

- 7.1
- nigthly
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to keep nightly in there with allowed failures.

Copy link
Member Author

Choose a reason for hiding this comment

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

For some weird reason Travis was failing to run php nightly (version simply wasn't available) and the pipeline didn't work even though that one as allowed to fail. I will check it again.

Copy link
Contributor

Choose a reason for hiding this comment

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

That error seems unrelated, looks like you force-pushed the branch before Travis was able to grab the commit. :P

the pipeline didn't work even though that one as allowed to fail

Maybe there's a difference betwen errored and failed state.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added it back, but I had a different error before. Let's see if it happens again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now it works... I'm probably getting crazier 😜

fast_finish: true
include:
- php: 5.6
env: deps=low
Copy link
Contributor

Choose a reason for hiding this comment

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

We also need to keep a 7.1 run with deps low in the matrix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

@lcobucci
Copy link
Member Author

@Ocramius @mikeSimonson I think this is good to go, please take a look 😉

charset="UTF-8" yui="true" highlight="true" lowUpperBound="5"
highLowerBound="70" />
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason to remove those two configurations ?
They are quite handy to work locally.

The rest of the PR is GTG for me.

Copy link
Member

Choose a reason for hiding this comment

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

@mikeSimonson you can always create your customized phpunit.xml locally: it overrides the .dist file and allows you to have custom settings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly 😁

@Ocramius Ocramius assigned Ocramius and unassigned lcobucci Aug 21, 2017
}

/**
* TODO: move SqlFileWriter's behaviour to this class - and kill it with fire (on the next major release)
Copy link
Member

Choose a reason for hiding this comment

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

TODO? :-P

Copy link
Member

Choose a reason for hiding this comment

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

Can you spawn an issue for this TODO?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was just waiting to get it merged to open the issueS 😜

$result = $writer->write($queriesByVersion, $direction);

// SqlFileWriter#write() returns `bool|int` but all clients expect it to be `bool` only
return $result !== false && $result > 0;
Copy link
Member

Choose a reason for hiding this comment

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

Isn't a (bool) cast sufficient?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it is, silly me...

*/
public function write(string $path, string $direction, array $queriesByVersion) : bool
{
$writer = new SqlFileWriter(
Copy link
Member

Choose a reason for hiding this comment

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

What about the injected writer?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't get what you mean, this is the implementation of the injected writer. I just don't wanted to implement everything here at this moment, it feels way too far from the scope of the PR.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, missed that you are actually using $this->outputWriter 🤦‍♂️

@Ocramius Ocramius assigned lcobucci and unassigned Ocramius Aug 21, 2017
Since we're actually not using it anymore.
Fixing a small issue that was preventing us to have at least the level 3.
Droping Mockery and making the test suite way faster.
Since we're now requiring >=3.3.
Since we're requiring 2.6 now.
So that we can remove hard dependencies from the code.
By relying on the configured query writer
@Ocramius Ocramius dismissed mikeSimonson’s stale review August 25, 2017 07:06

Review changes applied

@Ocramius
Copy link
Member

🚢

@Ocramius Ocramius merged commit 17f61e9 into master Aug 25, 2017
@Ocramius Ocramius deleted the align-project-settings branch August 25, 2017 07:07
@Ocramius Ocramius assigned Ocramius and unassigned lcobucci Aug 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants