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

Cannot add multiple dependencies to test #6675

Closed
mbrodala opened this issue Jul 12, 2023 · 0 comments · Fixed by #6676
Closed

Cannot add multiple dependencies to test #6675

mbrodala opened this issue Jul 12, 2023 · 0 comments · Fixed by #6676

Comments

@mbrodala
Copy link
Contributor

What are you trying to achieve?

I want to add multiple dependencies to a test.

What do you get instead?

An error occurs due to string (single dependency) vs. array (multiple dependencies) type mismatch.

Provide console output if related. Use -vvv mode for more details.

$ codecept run <suite> FooCest
Codeception PHP Testing Framework v5.0.10 https://helpukrainewin.org/
Fatal error: Uncaught TypeError: str_contains(): Argument #1 ($haystack) must be of type string, array given in /.../vendor/codeception/codeception/src/Codeception/Test/Cest.php:246
Stack trace:
#0 /.../vendor/codeception/codeception/src/Codeception/Test/Cest.php(246): str_contains(Array, ':')
#1 /.../vendor/codeception/codeception/src/Codeception/Suite.php(159): Codeception\Test\Cest->fetchDependencies()
#2 /.../vendor/codeception/codeception/src/Codeception/Suite.php(138): Codeception\Suite->getDependencies(Object(Codeception\Test\Cest))
#3 /.../vendor/codeception/codeception/src/Codeception/SuiteManager.php(93): Codeception\Suite->reorderDependencies()
#4 /.../vendor/codeception/codeception/src/Codeception/Codecept.php(258): Codeception\SuiteManager->loadTests('FooCest')
#5 /.../vendor/codeception/codeception/src/Codeception/Codecept.php(216): Codeception\Codecept->runSuite(Array, '<suite>', 'FooCest')
#6 /.../vendor/codeception/codeception/src/Codeception/Command/Run.php(435): Codeception\Codecept->run('<suite>', 'FooCest', Array)
#7 /.../vendor/symfony/console/Command/Command.php(326): Codeception\Command\Run->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /.../vendor/symfony/console/Application.php(1063): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /.../vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand(Object(Codeception\Command\Run), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /.../vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /.../vendor/codeception/codeception/src/Codeception/Application.php(112): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /.../vendor/codeception/codeception/app.php(45): Codeception\Application->run()
#13 /.../vendor/codeception/codeception/app.php(46): {closure}()
#14 /.../vendor/codeception/codeception/codecept(7): require('/.../v...')
#15 /.../vendor/bin/codecept(119): include('/.../v...')
#16 {main}
  thrown in /.../vendor/codeception/codeception/src/Codeception/Test/Cest.php on line 246
PHP Fatal error:  Uncaught TypeError: str_contains(): Argument #1 ($haystack) must be of type string, array given in /.../vendor/codeception/codeception/src/Codeception/Test/Cest.php:246

Provide test source code if related

use Codeception\Attribute\Depends;

final class FooCest
{
    public function testFirst (): void
    {
    }

    public function testSecond (): void
    {
    }

    #[Depends('testFirst')]
    #[Depends('testSecond')]
    public function testThird (): void
    {
    }
}

Details

  • Codeception version: 5.0.10
  • PHP Version: 8.1
  • Operating System: Ubuntu
  • Installation type: Composer
  • List of installed packages (composer show)
  • Suite configuration:
# paste suite config here
mbrodala added a commit to mbrodala/Codeception that referenced this issue Jul 12, 2023
The Depends attribute can be added multiple times to tests now to indicate dependencies on various other tests.

Fixes Codeception#6675
mbrodala added a commit to mbrodala/Codeception that referenced this issue Jul 12, 2023
The Depends attribute can be added multiple times to tests now to indicate dependencies on various other tests.

Fixes Codeception#6675
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 a pull request may close this issue.

1 participant