Hello Andrew ! (and anyone else who wishes to contribute) Reference your comment on "You should never add/edit/remove any file maintained by a package manager", I think that my case is an exception. With the assistance of another developer I have developed a fix for a "cake bake" issue. My challenge is to develop a test case for the change.
See https://github.com/cakephp/bake/issues/35 . I have a change to /vendor/cakephp/bake/src/Template/Bake/Element/form.ctp which solves the problem. Following your suggestions I tried a few variations. First, I used the imbedded phpunit in cakephp on my existing structure on the /vendor side. Then on the corresponding structure under /tests. In both cases the results are the same. I then tried the C:/bin/phpunit. Same results. (Conclusion, it does not matter which phpunit I use.) I noticed vendor/cakephp/bake/tests/TestCase/View/BakeViewTest.php which is part of the composer delivered cakephp system. I tried phpunit on that file and everything seems to work correctly. Conclusion: There must be some setup detail missing in the documented example in the Testing section ? Do you have any ideas following this additional information ? I am wondering if I need to understand what is going on with E:\web\cake3-rc2\phpunit.xml.dist . (See previous reply for content.) Regards Lorne My results are shown below. ------------------ E:\web\cake3-rc2>php vendor/phpunit/phpunit/phpunit --version PHPUnit 4.5.0 by Sebastian Bergmann and contributors. ------------------ E:\web\cake3-rc2>php vendor/phpunit/phpunit/phpunit vendor/cakephp/bake/tests/TestCase/View/Helper/ProgressHelperTest.php PHPUnit 4.5.0 by Sebastian Bergmann and contributors. Configuration read from E:\web\cake3-rc2\phpunit.xml.dist Fatal error: Class 'App\View\Helper\ProgressHelper' not found in E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\Helper\ProgressHelperTest.php on line 15 Call Stack: 0.0000 121872 1. {main}() E:\web\cake3-rc2\vendor\phpunit\phpunit\phpunit:0 0.0100 474688 2. PHPUnit_TextUI_Command::main() E:\web\cake3-rc2\vendor\phpunit\phpunit\phpunit:36 0.0100 478624 3. PHPUnit_TextUI_Command->run() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\TextUI\Command.php:104 0.2000 3402520 4. PHPUnit_TextUI_TestRunner->doRun() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\TextUI\Command.php:152 0.2200 3723104 5. PHPUnit_Framework_TestSuite->run() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:398 0.2300 3734232 6. PHPUnit_Framework_TestCase->run() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestSuite.php:716 0.2300 3734976 7. PHPUnit_Framework_TestResult->run() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:693 0.2600 3790704 8. PHPUnit_Framework_TestCase->runBare() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestResult.php:609 0.2900 3880808 9. App\Test\TestCase\View\Helper\ProgressHelperTest->setUp() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:733 ------------------ E:\web\cake3-rc2>php vendor/phpunit/phpunit/phpunit tests/TestCase/View/Helper/ProgressHelperTest.php PHPUnit 4.5.0 by Sebastian Bergmann and contributors. Configuration read from E:\web\cake3-rc2\phpunit.xml.dist Fatal error: Class 'App\View\Helper\AppHelper' not found in E:\web\cake3-rc2\src\View\Helper\ProgressHelper.php on line 5 Call Stack: 0.0000 121856 1. {main}() E:\web\cake3-rc2\vendor\phpunit\phpunit\phpunit:0 0.0100 474648 2. PHPUnit_TextUI_Command::main() E:\web\cake3-rc2\vendor\phpunit\phpunit\phpunit:36 0.0100 478584 3. PHPUnit_TextUI_Command->run() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\TextUI\Command.php:104 0.1200 3402512 4. PHPUnit_TextUI_TestRunner->doRun() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\TextUI\Command.php:152 0.1400 3723088 5. PHPUnit_Framework_TestSuite->run() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:398 0.1400 3734216 6. PHPUnit_Framework_TestCase->run() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestSuite.php:716 0.1400 3734960 7. PHPUnit_Framework_TestResult->run() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:693 0.1600 3790688 8. PHPUnit_Framework_TestCase->runBare() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestResult.php:609 0.1600 3880760 9. App\Test\TestCase\View\Helper\ProgressHelperTest->setUp() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:733 0.1800 4539216 10. spl_autoload_call() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:15 0.1800 4539256 11. Composer\Autoload\ClassLoader->loadClass() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:15 0.1800 4539352 12. Composer\Autoload\includeFile() E:\web\cake3-rc2\vendor\composer\ClassLoader.php:301 0.1800 4542304 13. include('E:\web\cake3-rc2\src\View\Helper\ProgressHelper.php') E:\web\cake3-rc2\vendor\composer\ClassLoader.php:412 ------------------ E:\web\cake3-rc2>phpunit tests/TestCase/View/Helper/ProgressHelperTest.php PHPUnit 4.5.0 by Sebastian Bergmann and contributors. Configuration read from E:\web\cake3-rc2\phpunit.xml.dist Fatal error: Class 'App\View\Helper\AppHelper' not found in E:\web\cake3-rc2\src\View\Helper\ProgressHelper.php on line 5 Call Stack: 0.0300 441904 1. {main}() C:\bin\phpunit.phar:0 0.0300 669064 2. PHPUnit_TextUI_Command::main() C:\bin\phpunit.phar:722 0.0300 673008 3. PHPUnit_TextUI_Command->run() phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:104 0.1400 3838088 4. PHPUnit_TextUI_TestRunner->doRun() phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:152 0.1600 4158688 5. PHPUnit_Framework_TestSuite->run() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:398 0.1700 4169784 6. PHPUnit_Framework_TestCase->run() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestSuite.php:716 0.1700 4170528 7. PHPUnit_Framework_TestResult->run() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:693 0.1800 4226264 8. PHPUnit_Framework_TestCase->runBare() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestResult.php:609 0.1800 4316496 9. App\Test\TestCase\View\Helper\ProgressHelperTest->setUp() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:733 0.2000 4974864 10. spl_autoload_call() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:15 0.2000 4974904 11. Composer\Autoload\ClassLoader->loadClass() E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:15 0.2000 4975000 12. Composer\Autoload\includeFile() E:\web\cake3-rc2\vendor\composer\ClassLoader.php:301 0.2000 4977952 13. include('E:\web\cake3-rc2\src\View\Helper\ProgressHelper.php') E:\web\cake3-rc2\vendor\composer\ClassLoader.php:412 ------------------ E:\web\cake3-rc2>phpunit vendor/cakephp/bake/tests/TestCase/View/BakeViewTest.php PHPUnit 4.5.0 by Sebastian Bergmann and contributors. Configuration read from E:\web\cake3-rc2\phpunit.xml.dist FFFFF Time: 510 ms, Memory: 5.50Mb There were 5 failures: 1) Bake\Test\TestCase\View\BakeViewTest::testRenderTemplate variables in erb-style tags should be evaluated Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ #Warning: Strings contain different line endings! The value of aVariable is: 123. E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\BakeViewTest.php:75 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:152 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:104 2) Bake\Test\TestCase\View\BakeViewTest::testRenderIgnorePhpTags variables in php tags should be treated as strings Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ #Warning: Strings contain different line endings! The value of aVariable is: 123. Not <?php echo $aVariable ?>. E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\BakeViewTest.php:89 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:152 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:104 3) Bake\Test\TestCase\View\BakeViewTest::testRenderIgnorePhpShortTags variables in php tags should be treated as strings Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ #Warning: Strings contain different line endings! The value of aVariable is: 123. Not <?= $aVariable ?>. E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\BakeViewTest.php:103 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:152 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:104 4) Bake\Test\TestCase\View\BakeViewTest::testRenderNewlines Tags at the end of a line should not swallow new lines when rendered Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ -There should be a newline about here: -And this should be on the next line. +There should be a newline about here: And this should be on the next line. There should be no new line after this E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\BakeViewTest.php:123 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:152 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:104 5) Bake\Test\TestCase\View\BakeViewTest::testSwallowLeadingWhitespace Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ '<?php // Dummy php code ?> - 1 - 2 - 3 - + 1 2 3 number number number This should make no difference: - 1 - 2 - 3 -And the previous line should not have leading whitespace. + 1 2 3And the previous line should not have leading whitespace. ' E:\web\cake3-rc2\vendor\cakephp\cakephp\src\TestSuite\TestCase.php:166 E:\web\cake3-rc2\vendor\cakephp\cakephp\src\TestSuite\StringCompareTrait.php:47 E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\BakeViewTest.php:134 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:152 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:104 FAILURES! Tests: 5, Assertions: 5, Failures: 5. On Sunday, February 15, 2015 at 9:44:24 PM UTC-5, Andrew Lechowicz wrote: > > I was going to say: > > I'm curious, what happens if you run it with the composer installed >> phpunit? Your command will be something like >> `vendor/bin/phpunit tests/TestCase/View/Helper/`. > > > But then I noticed your path: `E:\web\cake3-rc2\vendor\`. You should > never add/edit/remove any file maintained by a package manager (composer in > this case). Move these into the respective folders in src and you should be > good to go. > > On Sunday, February 15, 2015 at 8:29:09 PM UTC-5, Lorne Dudley wrote: >> >> Hello Andrew ! >> >> OK, I tried this. >> E:\web\cake3-rc2>php composer.phar dump-autoload >> Generating autoload files >> >> Then >> E:\web\cake3-rc2>phpunit >> vendor/cakephp/bake/tests/TestCase/View/Helper/ProgressHelperTest.php >> PHPUnit 4.5.0 by Sebastian Bergmann and contributors. >> >> Configuration read from E:\web\cake3-rc2\phpunit.xml.dist >> >> >> Fatal error: Class 'App\View\Helper\ProgressHelper' not found in >> E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\Helper\ProgressHelperTest.php >> >> on line 15 >> >> Call Stack: >> 0.0300 441920 1. {main}() C:\bin\phpunit.phar:0 >> 0.0300 669080 2. PHPUnit_TextUI_Command::main() >> C:\bin\phpunit.phar:722 >> 0.0300 673024 3. PHPUnit_TextUI_Command->run() >> phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:104 >> 0.2120 3838104 4. PHPUnit_TextUI_TestRunner->doRun() >> phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:152 >> 0.2320 4158704 5. PHPUnit_Framework_TestSuite->run() >> E:\web\cake3-rc2\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:398 >> 0.2420 4169832 6. PHPUnit_Framework_TestCase->run() >> E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestSuite.php:716 >> 0.2420 4170576 7. PHPUnit_Framework_TestResult->run() >> E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:693 >> 0.2520 4226312 8. PHPUnit_Framework_TestCase->runBare() >> E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestResult.php:609 >> 0.2620 4316576 9. >> App\Test\TestCase\View\Helper\ProgressHelperTest->setUp() >> E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:733 >> >> Here are my file contents and their locations. >> >> E:\web\cake3-rc2\phpunit.xml.dist >> ================================= >> <?xml version="1.0" encoding="UTF-8"?> >> <phpunit >> colors="true" >> processIsolation="false" >> stopOnFailure="false" >> syntaxCheck="false" >> bootstrap="./tests/bootstrap.php" >> > >> <php> >> <ini name="memory_limit" value="-1"/> >> <ini name="apc.enable_cli" value="1"/> >> </php> >> >> <!-- Add any additional test suites you want to run here --> >> <testsuites> >> <testsuite name="App Test Suite"> >> <directory>./tests/TestCase</directory> >> </testsuite> >> <!-- Add plugin test suites here. --> >> </testsuites> >> >> <!-- Setup a listener for fixtures --> >> <listeners> >> <listener >> class="\Cake\TestSuite\Fixture\FixtureInjector" >> >> file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php"> >> <arguments> >> <object class="\Cake\TestSuite\Fixture\FixtureManager" /> >> </arguments> >> </listener> >> </listeners> >> >> </phpunit> >> >> E:\web\cake3-rc2\vendor\cakephp\bake\src\View\Helper\ProgressHelper.php >> ======================================================================= >> <?php >> namespace App\View\Helper; >> >> class ProgressHelper extends AppHelper >> { >> public function bar($value) >> { >> $width = round($value / 100, 2) * 100; >> return sprintf( >> '<div class="progress-container"> >> <div class="progress-bar" style="width: %s%%"></div> >> </div>', $width); >> } >> } >> >> >> E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\Helper\ProgressHelperTest.php >> >> ====================================================================================== >> <?php >> namespace App\Test\TestCase\View\Helper; >> >> use App\View\Helper\ProgressHelper; >> use Cake\TestSuite\TestCase; >> use Cake\View\View; >> >> class ProgressHelperTest extends TestCase >> { >> >> public function setUp() >> { >> parent::setUp(); >> $View = new View(); >> $this->Progress = new ProgressHelper($View); >> } >> >> public function testBar() >> { >> $result = $this->Progress->bar(90); >> $this->assertContains('width: 90%', $result); >> $this->assertContains('progress-bar', $result); >> >> $result = $this->Progress->bar(33.3333333); >> $this->assertContains('width: 33%', $result); >> } >> >> } >> >> >> ====================================================================================== >> >> I am not at all confident that I have things placed in the correct >> directories. >> The documentation (PDF version, starting at page 559) does not clearly >> indicate where these items should be placed. >> I am guessing that the reference to the directory tests is on the vendor >> side. >> >> My long term goal is to learn enough about "Testing" so that I can >> develop a test for a change >> made to /vendor/cakephp/bake/src/Template/Bake/Element/form.ctp >> >> Any help or assistance for this new member of the cakephp community would >> be greatly appreciated. >> >> On Saturday, February 14, 2015 at 4:23:42 PM UTC-5, Andrew Lechowicz >> wrote: >>> >>> When something isn't loading the correct file, it smells like a composer >>> autoload issue or a namespace issue. Try running `composer dump-autoload`. >>> If that doesn't work try looking at your `use` blocks to see if you might >>> be missing something. >>> >>> On Friday, February 13, 2015 at 12:00:11 AM UTC-5, Lorne Dudley wrote: >>>> >>>> OK, I have made a little progress in trying to figure out what is >>>> wrong. My conclusion is that there are some steps missing in the >>>> documentation. >>>> I hope that perhaps one of the core developers might comment as to what >>>> might be wrong. >>>> >>>> I was able to make the "Fatal error: Class >>>> 'App\View\Helper\ProgressHelper' not found" error to go away by placing >>>> ProgressHelper.php in the same directory as ProgressHelperTest.php. >>>> However I still get a failure further on -- "Fatal error: Class >>>> 'Cake\TestSuite\TestCase' not found". >>>> >>>> It appears that all searches for dependent components take place in the >>>> same directory as ProgressHelperTest.php at the moment. >>>> >>>> So ... how do I fix this so that searches for dependent components >>>> are resolved properly ??? What is missing in the documentation ? >>>> >>>> Below are my two latest attempts to get this to execute properly. >>>> >>>> E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\Helper>phpunit >>>> ProgressHelperTest.php >>>> >>>> Fatal error: Class 'Cake\TestSuite\TestCase' not found in >>>> E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\Helper\ProgressHelperTest.php >>>> >>>> on line 9 >>>> >>>> Call Stack: >>>> 0.0340 441904 1. {main}() C:\bin\phpunit.phar:0 >>>> 0.0360 669064 2. PHPUnit_TextUI_Command::main() >>>> C:\bin\phpunit.phar:722 >>>> 0.0360 673008 3. PHPUnit_TextUI_Command->run() >>>> phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:104 >>>> 0.0430 907096 4. PHPUnit_Runner_BaseTestRunner->getTest() >>>> phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:126 >>>> 0.0430 907120 5. >>>> PHPUnit_Runner_BaseTestRunner->loadSuiteClass() >>>> phar://C:/bin/phpunit.phar/phpunit/Runner/BaseTestRunner.php:70 >>>> 0.0440 923936 6. >>>> PHPUnit_Runner_StandardTestSuiteLoader->load() >>>> phar://C:/bin/phpunit.phar/phpunit/Runner/BaseTestRunner.php:125 >>>> 0.0450 948688 7. PHPUnit_Util_Fileloader::checkAndLoad() >>>> phar://C:/bin/phpunit.phar/phpunit/Runner/StandardTestSuiteLoader.php:43 >>>> 0.0470 948848 8. PHPUnit_Util_Fileloader::load() >>>> phar://C:/bin/phpunit.phar/phpunit/Util/Fileloader.php:42 >>>> 0.0470 954616 9. >>>> include_once('E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\Helper\ProgressHelperTest.php') >>>> >>>> phar://C:/bin/phpunit.phar/phpunit/Util/Fileloader.php:58 >>>> >>>> >>>> E:\web\cake3-rc2\vendor\cakephp\bake>phpunit >>>> tests/TestCase/View/Helper/ProgressHelperTest.php >>>> PHPUnit 4.5.0 by Sebastian Bergmann and contributors. >>>> >>>> Configuration read from >>>> E:\web\cake3-rc2\vendor\cakephp\bake\phpunit.xml.dist >>>> >>>> >>>> Fatal error: Class 'App\View\Helper\ProgressHelper' not found in >>>> E:\web\cake3-rc2\vendor\cakephp\bake\tests\TestCase\View\Helper\ProgressHelperTest.php >>>> >>>> on line 15 >>>> >>>> Call Stack: >>>> 0.0280 441920 1. {main}() C:\bin\phpunit.phar:0 >>>> 0.0310 669088 2. PHPUnit_TextUI_Command::main() >>>> C:\bin\phpunit.phar:722 >>>> 0.0310 673032 3. PHPUnit_TextUI_Command->run() >>>> phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:104 >>>> 0.1030 2762848 4. PHPUnit_TextUI_TestRunner->doRun() >>>> phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php:152 >>>> 0.1180 3083496 5. PHPUnit_Framework_TestSuite->run() >>>> E:\web\cake3-rc2\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:398 >>>> 0.1250 3094624 6. PHPUnit_Framework_TestCase->run() >>>> E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestSuite.php:716 >>>> 0.1250 3095368 7. PHPUnit_Framework_TestResult->run() >>>> E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:693 >>>> 0.1320 3150720 8. PHPUnit_Framework_TestCase->runBare() >>>> E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestResult.php:609 >>>> 0.1360 3240640 9. >>>> App\Test\TestCase\View\Helper\ProgressHelperTest->setUp() >>>> E:\web\cake3-rc2\vendor\phpunit\phpunit\src\Framework\TestCase.php:733 >>>> >>>> >>>> -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.