-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add is_windows()
global function
#6884
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read conflicting options on whether uname()
or if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
is better. If you feel confident this is the way then I trust you.
We should find a way to make this mockable so people can test their Windows-specific code without being on Windows. My initial thought is to add a parameter to set/clear a local static value:
public function testWindowsUsesBananas() {
is_windows(true);
$this->assertSame('bananas', $this->execute('getFruitByOs');
is_windows(null);
}
It's a little bit hacky but thus is functional programming 🤷♂️ Only other alternative might be to stick the value on CodeIgniter along with $context.
On WSL, PHP_OS is Linux so the check would fail on that. DIRECTORY_SEPARATOR is also "/" on WSL. |
De we really need to detect WSL as Windows? It seems WSL supports Chmod/Chown. |
It seems the article is referring to the native filesystem functions, not the PHP equivalents. As tested in WSL, PHP's |
Do you mount your drive with In my understanding, PHP's chmod() is kind of wrapper for the native filesystem functions. |
Thanks for the link! I was not able to make it work on the first try. I first need to uninstall all php related from WSL, then proceeding with unmounting and remounting: sudo apt remove -y php8.2-*
cd /
sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata,uid=1000,gid=1000 Now, $ vendor/bin/phpunit --filter GeneratorsTest --no-coverage
PHPUnit 9.5.26 by Sebastian Bergmann and contributors.
Runtime: PHP 8.2.0RC5
Configuration: /mnt/c/Users/P/Desktop/Web Dev/CodeIgniter4/phpunit.xml.dist
........ 8 / 8 (100%)
Nexus\PHPUnit\Extension\Tachycardia identified these 4 slow tests:
⚠ Took 5.50s from 0.50s limit to run CodeIgniter\\Commands\\GeneratorsTest::testGenerateFileCreated
⚠ Took 1.52s from 0.50s limit to run CodeIgniter\\Commands\\GeneratorsTest::testSuffixingHasNoEffect
⚠ Took 1.36s from 0.50s limit to run CodeIgniter\\AutoReview\\FrameworkCodeTest::testEachTestClassHasCorrectGroupAnnotation with data set \"CodeIgniter\\Commands\\GeneratorsTest\"
⚠ Took 0.54s from 0.50s limit to run CodeIgniter\\Commands\\GeneratorsTest::testGenerateFileFailsOnUnwritableDirectory
Time: 00:10.806, Memory: 44.00 MB
OK (8 tests, 14 assertions)
|
I'll update the PR to limit the function on native Windows. |
9489bdd
to
8d77ff7
Compare
Please update the docs. Otherwise looks good. |
8d77ff7
to
79dfa5a
Compare
79dfa5a
to
30a6bb1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @paulbalandan! Looks good.
Thank you very much for the improvements, from Argentina |
Description
is_windows()
global function, for uniform detection of Windows platformCLI::isWindows()
, as platform detection is not limited to consoleRelated: #6882
Checklist: