Skip to content

Added tests, fixed a couple of bugs, added new feature #19

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 6 commits into from
May 24, 2018

Conversation

crashkonijn
Copy link
Collaborator

Hi there!

I've been planning to use this package for one of my project in the near future, but after a lot of thinking I came to the conclusion that I would need a new feature in this package since that would benefit my project the most: Being able to select a version based on a moment in time.

So what's the use case for this you ask? Let's say you have a Product and an Order model, an order can contain products. Because it's possible for a product to be updated (price) you might want to save the total amount that had to be payed in the order model to make sure the price of your order doesn't change.

The change that's included lets you do something more awesome, if you make the price versionable:

class Order
{
    public function products()
    {
        return $this->belongsToMany()->moment($this->created_at);
    }
}

Fixes

  • Apparently I made the exact same fix as this: Update BuilderTrait.php #14
  • double inner join #15
  • Model::create() didn't set the latest_version, bricking things when updating that same model afterwards
  • Neither did update and save if I remember correctly

Tests

Because having tests is the key to having a stable, maintainable opensource project I added some tests. It doesn't fully cover everything yet but it does provide a nice base to add more tests where needed. Currently this is the coverage:

capture

Notes

  • It appears my computer thought it would be wise to change the line endings on some scripts. Sorry for the diff mess this gives.
  • The min PHP version has been updated to >= 7.1 due to phpunit requirements.

I hope you can accept this merge request, if there's any problems I'm glad to get your feedback.

Cheers!

@markusjwetzel
Copy link
Contributor

Thank you very much for the pull request, @crashkonijn! I have to say that currently I don't use this package in production, so it is kind of unmaintained, but I'm willing to assist everybody who wants to improve to this package.

It seems to me that you have some good ideas for this package and also put a lot of work into this pull request. If it is okay for you, I will give you collaborator rights, so you can merge pull requests yourself.

For the line endings: It would be nice to have clean diffs. Can you please try to fix the line endings? I think most editors these days have some settings for line endings, so this shouldn't be a big deal. If you can't find a fix, then please split up the pull request into two (first one for the line ending changes and second one for the other diffs).

@crashkonijn
Copy link
Collaborator Author

Hello @markusjwetzel!

Thanks for giving me this opportunity, I'd be glad to become a maintainer of this package! I'll fix the line endings and merge it tonight.

Thanks!

@crashkonijn
Copy link
Collaborator Author

I've changed the line endings, but I'll wait with merging for now since I'd like to try and get automated testing working on this package.

Something like https://scrutinizer-ci.com/, which is free for open source projects!

@markusjwetzel
Copy link
Contributor

Thanks! I've approved your request for scrutinizer ci.

@crashkonijn
Copy link
Collaborator Author

Thanks!

Unfortunately scrutinizer still doesn't allow me to add this project, I've send them a question about it. If I can't get that working by tomorrow I'll just merge this branch for now.

In the meantime I did increase code coverage:

capture_02

@crashkonijn
Copy link
Collaborator Author

Hello @markusjwetzel,

I've talked it over with the scrutinizer support and apparently I still don't have the correct permissions to do this apparently. Perhaps you could find the time to set it up for this project?

In the mean time I'll merge this for now.

@crashkonijn crashkonijn merged commit f8e2ef4 into ProAI:master May 24, 2018
@markusjwetzel
Copy link
Contributor

@crashkonijn I've added this repo to my scrutinizer account. It's the first time I use scrutinizer, but it seems to me that everything is set up now. If not, just let me know. :)

@crashkonijn
Copy link
Collaborator Author

@markusjwetzel awesome thanks!

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