- Issue created by @phenaproxima
- Assigned to wim leers
- Status changed to Needs review
almost 2 years ago 12:31am 10 March 2023 - @phenaproxima opened merge request.
- πΊπΈUnited States phenaproxima Massachusetts
Assigning to Wim to review and hopefully commit this so we can finally get rid of ComposerUtility.
- Status changed to Needs work
almost 2 years ago 8:45am 10 March 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
This blocks π Remove our runtime dependency on composer/composer: remove ComposerUtility Fixed , tagging accordingly.
The code looks great! π
/opt/homebrew/bin/php /private/var/folders/x1/mlh998q15c70vs7_y8s1mgqm0000gp/T/ide-phpunit.php --configuration /Users/wim.leers/core/core/phpunit.xml --filter "/(Drupal\\Tests\\package_manager\\Kernel\\StageTest::testValidateRequirements)( .*)?$/" --test-suffix StageTest.php /Users/wim.leers/core/modules/contrib/automatic_updates/package_manager/tests/src/Kernel Testing started at 9:41 AM ... PHPUnit 9.5.28 by Sebastian Bergmann and contributors. Testing /Users/wim.leers/core/modules/contrib/automatic_updates/package_manager/tests/src/Kernel ................................................................. 65 / 66 ( 98%) . 66 / 66 (100%) Time: 02:32.646, Memory: 10.00 MB OK (66 tests, 198 assertions) Process finished with exit code 0
π
\Drupal\Tests\package_manager\Kernel\StageTest::testValidateRequirements()
test now takes 2.5 minutes to run, that's not acceptable β¦ converting this to a unit test. - Issue was unassigned.
- Status changed to RTBC
almost 2 years ago 9:03am 10 March 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Will merge as soon as this comes back green β which it will!
I did not change anything materially:
- I moved the regexes to private constants
- I made the method static
- I moved the test from a kernel test to a unit test (which requires reflection, but
ProcessFactoryTest
already did that) to avoid this making the test suite >10% slower π
-
Wim Leers β
committed dd9ecbf1 on 3.0.x authored by
phenaproxima β
Issue #3347031 by phenaproxima, Wim Leers: Stage::validatePackageNames...
-
Wim Leers β
committed dd9ecbf1 on 3.0.x authored by
phenaproxima β
- Status changed to Fixed
almost 2 years ago 10:21am 10 March 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
After searching for 30 minutes, I found d.o's "Merge" button π³
- πΊπΈUnited States phenaproxima Massachusetts
Nice.
I have no objections to your changes, apart from calling
self
on a protected static method (if it's protected, we should usestatic::
invocation). But that's not a problem for now and easily fixed later.Fun fact: the test coverage previously was a unit test. I too was disappointed I had to convert it to a kernel test. But hey, sometimes you need reflection, and this is one of those times. Later we can re-evaluate how much of this test coverage is actually needed (vs. how much we can trust Composer to take care of for us) and trim it down.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
About a year ago I would have agreed with you about calling it using
static::
. But not anymore, because astatic function
just means it cannot access$this
. But invoking a method usingstatic::methodName()
is only needed for Late Static Binding, which is only relevant when dealing with inheritance. That's not applicable here.So
self::methodName()
is the closest equivalent to$this->methodName()
that does not try to pass$this
into the invoked method!Pretty interesting, eh? π€
- πΊπΈUnited States phenaproxima Massachusetts
I know
static::
is for late static bindings, but this is a protected method, which means that inheritance is relevant. Even if it were private, I'd have actually called forstatic
, since that would allow us to easily open it up in the future if we wanted to.Nonetheless, it's not a big deal; if we're lucky we'll be able to remove this method entirely anyway.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Ah β¦ well β¦ this is only
protected
to allow subclasses to override::require()
, nobody should be overriding::validateRequirements()
! - πΊπΈUnited States phenaproxima Massachusetts
Then we should probably make it
final
, if we end up keeping it. :) Automatically closed - issue fixed for 2 weeks with no activity.