Skip to content

Conversation

@ipundit
Copy link
Contributor

@ipundit ipundit commented Sep 4, 2023

composer test now takes optional parameters

composer test [fileName [filter]]

With no parameters

composer test

runs

vendor/bin/phpunit

With a file name

composer test dateTime

runs

vendor/bin/phpunit test/DateTimeTest.php

Note the prepending of test/, the fix in capitalization, and appending Test.php

With a file name and filter

composer test dateTime format

runs

vendor/bin/phpunit --filter format test/DateTimeTest.php

ipundit added 20 commits August 31, 2023 18:10
…at capitalization for attribute names are retained. So the short form for New York is now NY instead of ny. test/model/Author, Book, and Venue now have those strtoupper() workarounds in getter/setter methods removed as it's done in Model.php
…rcased in Model.php in order to be case insensitive.
…at capitalization for attribute names are retained. So the short form for New York is now NY instead of ny. test/model/Author, Book, and Venue now have those strtoupper() workarounds in getter/setter methods removed as it's done in Model.php
…rcased in Model.php in order to be case insensitive.
…cord

# Conflicts:
#	test/ActiveRecordTest.php
#	test/models/Book.php
…Disable it so that regression does not timeout.
…d#35:

Authors table now has a column that is camel cased: firstName
Added tests that demonstrate case insensitivity when accessing this firstName column
- Correct link to contributing.md
@shmax
Copy link
Contributor

shmax commented Sep 4, 2023

Aren't you kind of reinventing the wheel, here? Isn't a lot of this already possible using the -- pass-through? eg:

composer test -- test/DateTimeTest.php

if you don't like typing the name of the folder or ".php", you can do this:

composer test -- --filter DateTimeTest

single test:

composer test -- --filter DateTimeTest::testSetIsoDate

@ipundit
Copy link
Contributor Author

ipundit commented Sep 4, 2023

You can still do that if you want after this commit:

vendor/bin/phpunit --filter DateTimeTest::testSetIsoDate

but, this is more convenient:

composer test dateTime setIsoDate

It's a few things less to type and it's easier to do progressively larger tests. In my dev cycle, I do:

composer test dateTime setIsoDate
composer test dateTime
composer test

In the old way, you'd have to:

composer test -- --filter DateTimeTest::testSetIsoDate
composer test -- --filter DateTimeTest
composer test

Which would you rather type? Which is easier for a new developer to learn, especially since running:

composer test

gives hints for:

To run just the tests in test/CallbackTest.php, try: composer test callback
To run a specific test in test/DateTimeTest.php, try: composer test dateTime testSetIsoDate

Discoverability is important for new developers, and convenience, especially if it's optional to use, is useful for all developers.

@shmax
Copy link
Contributor

shmax commented Sep 4, 2023

I dunno, I'm still not convinced. Developers already accustomed to using the standard phpunit API now have to learn yours, so I guess it's up for debate which is more convenient.

And for what it's worth, I never use the CLI for tests; I use PHPStorm, and I can just right click on folders, test classes, or individual tests and choose "Run" or "Debug".

If you really want to insist on it I guess we can merge this, but I think it would be more appropriate for you to develop this tool in its own composer package, and we can import it as a dependency once it's matured a bit.

composer test -- test/DateTimeTest.php
composer test -- --filter DateTimeTest
composer test -- --filter DateTimeTest::testSetIsoDate

now all work too
@ipundit
Copy link
Contributor Author

ipundit commented Sep 4, 2023

All these tests now work too:

composer test test/DateTimeTest.php
composer test -- test/DateTimeTest.php
composer test -- --filter DateTimeTest
composer test -- --filter DateTimeTest::testSetIsoDate

As well as:

composer test dateTime setIsoDate
composer test dateTime
composer test

Merge and let future developers use whatever syntax they want to use? Developers can write personal Windows.bat files or shell files if they wish, but using composer test makes the convenience scripts more cross-platform.

@shmax
Copy link
Contributor

shmax commented Sep 4, 2023

I think I can live with that. Please fix the CI, and we'll move forward.

"ActiveRecord\\": "lib/"
}
},
"autoload-dev": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, nice, I was wondering what to do about that 👍

Copy link
Contributor

@shmax shmax left a comment

Choose a reason for hiding this comment

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

Nice 👍

@shmax shmax merged commit fc545aa into php-activerecord:master Sep 4, 2023
@ipundit ipundit deleted the ComposerTest branch September 5, 2023 16:45
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