Skip to content
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

feat: spark make:test creates test files in /tests/ directory v2 #8388

Merged
merged 7 commits into from
Jan 23, 2024

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Dec 30, 2023

Description
Supersedes #8374

  • make:test creates test files in /tests/ directory
  • add tests/system for namespace CodeIgniter

E.g.,

$ ./spark make:test FooTest 
File created: ROOTPATH/tests/FooTest.php
$ ./spark make:test Bar/FooTest 
File created: ROOTPATH/tests/Bar/FooTest.php
$ ./spark make:test CodeIgniter\\Commands\\FooTest
File created: ROOTPATH/tests/system/Commands/FooTest.php

If you set:

public $psr4 = [
    APP_NAMESPACE => [APPPATH, TESTPATH . 'app'],
];
$ ./spark make:test App\\Controllers\\FooTest
File created: ROOTPATH/tests/app/Controllers/FooTest.php

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added enhancement PRs that improve existing functionalities 4.5 labels Dec 30, 2023
@kenjis kenjis force-pushed the feat-make-test-namespace-2 branch 2 times, most recently from f6ac660 to 9f25c39 Compare December 30, 2023 01:51
Copy link
Member

@lonnieezell lonnieezell left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks.

Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

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

Awesome!

@@ -237,7 +239,7 @@ protected function getNamespaces()
foreach ($this->autoloader->getNamespace() as $prefix => $paths) {
foreach ($paths as $path) {
if ($prefix === 'CodeIgniter') {
$system = [
$system[] = [
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a functionally-impactful change. Was this a bug?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see: this is to enable both directories to map to \CodeIgniter\. Could this cause other problems for existing code?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. The return value is originally an array list [['prefix' => prefix, 'path' => path], ...].
Adding an array for \CodeIgniter\ for test as a last element does no harm.

@kenjis kenjis requested a review from MGatner January 20, 2024 01:31
@kenjis kenjis merged commit 12c9255 into codeigniter4:4.5 Jan 23, 2024
47 checks passed
@kenjis kenjis deleted the feat-make-test-namespace-2 branch January 23, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.5 enhancement PRs that improve existing functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants