xepozz / test-it

A tool for generating files with tests cases based on class methods signatures.
18 stars 0 forks source link

Fatal error: Uncaught TypeError: str_replace(): Argument #1 ($search) must be of type array|string, null given in \Helper\PathFinder.php:19 #2

Open mambax7 opened 1 year ago

mambax7 commented 1 year ago

Unfortunately, I couldn't get it to work on PHP 8.2.1. Should I use a different version of PHP?

Fatal error: Uncaught TypeError: str_replace(): Argument #1 ($search) must be of type array|string, null given in \vendor\xepozz\test-it\src\Helper\PathFinder.php:19
Stack trace:
#0 \vendor\xepozz\test-it\src\Helper\PathFinder.php(19): str_replace(NULL, '', 'App\\Obituaries3...')
#1 \vendor\xepozz\test-it\src\TestGenerator\NamespaceGenerator.php(27): Xepozz\TestIt\Helper\PathFinder::translateNamespace('App\\Obituaries3...', 'C:\\wamp64\\www\\2...')
#2 \vendor\xepozz\test-it\src\Parser\ContextMethodVisitor.php(70): Xepozz\TestIt\TestGenerator\NamespaceGenerator->generate(Object(Xepozz\TestIt\Parser\Context), Array)
#3 \vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(230): Xepozz\TestIt\Parser\ContextMethodVisitor->leaveNode(Object(PhpParser\Node\Stmt\Namespace_))
#4 \vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(91): PhpParser\NodeTraverser->traverseArray(Array)
#5 \vendor\xepozz\test-it\src\TestGenerator.php(44): PhpParser\NodeTraverser->traverse(Array)
#6 \vendor\xepozz\test-it\test-it(39): Xepozz\TestIt\TestGenerator->process()
#7 \vendor\symfony\console\Command\Command.php(310): Closure->{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 \vendor\symfony\console\SingleCommandApplication.php(52): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 \vendor\symfony\console\Application.php(1022): Symfony\Component\Console\SingleCommandApplication->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 \vendor\symfony\console\Application.php(314): Symfony\Component\Console\Application->doRunCommand(Object(Symfony\Component\Console\SingleCommandApplication), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 \vendor\symfony\console\Application.php(168): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 \vendor\symfony\console\SingleCommandApplication.php(65): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 \vendor\xepozz\test-it\test-it(42): Symfony\Component\Console\SingleCommandApplication->run()
#14 \vendor\bin\test-it(120): include('C:\\wamp64\\bin\\p...')
#15 {main}
  thrown in \vendor\xepozz\test-it\src\Helper\PathFinder.php on line 19
xepozz commented 1 year ago

Could you show your project or write a test in addition to existing ones?

xepozz commented 1 year ago

Probably you don't have autoload-dev section inside your composer.json?

mambax7 commented 1 year ago

Correct. What should I put there?

xepozz commented 1 year ago

You should map test namespace with a test directory. Same as here. It will be "App\\Tests\\": "tests" I suppose.

xepozz commented 1 year ago

@mambax7 have tried to fix the error? I have a few thoughts about workaround over it, but adding a few lines into composer.json is the simplest solution and even logically right.

mambax7 commented 1 year ago

I'm too busy right now, but hopefully in a week I'll try to dive into it again. Thanks for your tips/ideas!