Skip to content

Conversation

Zae
Copy link
Contributor

@Zae Zae commented Oct 29, 2015

First I wanted to change the library to make it possible to call the methods non-statically, after doing so I could not figure out why phpspec was not throwing any errors as it should, so I rewrote all the specs in phpunit.

Then I found out PHP allows you to call static methods non-statically so all my work was for nothing, or so I thought!

phpunit found that the fromRoman method in the Number class was not static and so not allowed to be called statically.

So, this pull request adds a lot of phpunit tests that found a bug that phpspec somehow missed and fixes a very tiny bug!

@defrag
Copy link
Member

defrag commented Oct 29, 2015

Thanks for finding this bug, but rewritting all tests? Seems too much. I know that some of our specs arent really specs, rather some integration tests for the facades and we do have a plan to improve them, but peronally i wouldnt go that far and replace just all of them with phpunit.
If you dont want to call static methods, why dont u just construct the objects behind them and call them non-staticly?

@Zae
Copy link
Contributor Author

Zae commented Oct 29, 2015

That's what I'm doing right now, but I didn't know that was possible in PHP before writing all these tests.

I didn't throw away the specs, they are still there, they simply do the same right now.
I just thought I'd send the pull request, was a waste to simply throw them all away after doing such a good job in finding that bug :-P

@norberttech
Copy link
Member

@Zae nice!
To be honest it was on my todo list for tomorrow. I was going to remove StringSpec, NumberSpec, DateTimeSpec and CollectionSpec, those specs are more interation tests rather than unit tests and I think it would be easier to test those facades with phpunit.

Also according to PSR standards you should use 4 spaces instead of tab for indention as mentioned in Contributing file

@@ -21,7 +21,9 @@
"symfony/yaml": "~2.3"
},
"require-dev": {
"phpspec/phpspec": "2.0.*"
"phpspec/phpspec": "2.0.*",
"phpunit/phpunit": "^3.0|^4.0|^5.0",
Copy link
Member

Choose a reason for hiding this comment

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

Because this is only dev dependency I think we can use highest version ^5.0

@Zae
Copy link
Contributor Author

Zae commented Oct 29, 2015

Hey Norbert,
Glad you like it.

I didn't think about the spaces, my company uses most of PSR-2 only with tabs, I'll change it along with the other suggestions you made.

Do you want me to squash all the commits into one when i'm done?

@Zae
Copy link
Contributor Author

Zae commented Oct 29, 2015

I did the changes and squashed all the test commits into one but left the one where I fixed the bug separate.

I added namespaces, changed to spaces

I changed the dev version requirement of phpunit, to 4.5 minimum, because that version includes prophecy for the first time and ^5.0 only supports >= php 5.6.

*/
public function preciseDifferenceDataProvider()
{
return array(
Copy link
Member

Choose a reason for hiding this comment

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

Maybe its a good idea to separate each test case per locale?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could, I thought it was easier and DRYer this way, simply add a new block to the dataprovider and you're good to go, the test code stays the same.

Copy link
Member

Choose a reason for hiding this comment

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

Im not totally sure if we should split those test cases. IMO this way is easier for new ppl to add tests for other languages.

@Zae
Copy link
Contributor Author

Zae commented Oct 30, 2015

Did the changes, but github says there are conflicts... Should I rebase on top of master?

@norberttech
Copy link
Member

Yes, please rebase against master

@norberttech
Copy link
Member

@Zae thanks! I gonna take it from here, we still need to add tests for languages that we currently support.

PHPUnit 4.5 is the first version that includes prophecy so we need at least that or the newest version
…e called statically, assuming $this from incompatible context
@Zae
Copy link
Contributor Author

Zae commented Oct 31, 2015

rebase complete!

@norberttech
Copy link
Member

@Zae Im closing this PR in favor of #50, history stays untouched you are still main author of this change, thanks!.

@norberttech norberttech closed this Nov 1, 2015
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.

3 participants