1

I've installed the latest version of CakePHP, then installed PHPUnit using PEAR and tried to get access using such link as

http://localhost/[project_name]/test.php

But as a result I've got a message that PHPUnit is not installed. I can't understand what the problem is. Are there any other ways to solve this problem ?

And is it possible not to install PHPUnit, but just copy all its files to, for example, Vendor directory of CakePHP and to use it locally just for one separate project ?

John Willemse
  • 6,608
  • 7
  • 31
  • 45
jekahm
  • 149
  • 1
  • 9
  • If you want to test it, you need PHPUnit -- http://stackoverflow.com/questions/12655136/install-phpunit-on-windows – cornelb Mar 12 '14 at 07:53

2 Answers2

1

I disagree with Mark. :)

The most easy way to install phpunit systemwide is using composer as described on their installation page:

For a system-wide installation via Composer, you can run:

composer global require 'phpunit/phpunit=3.7.*'
floriank
  • 25,546
  • 9
  • 42
  • 66
0

The easiest way in Win is https://github.com/dereuromark/cakephp-phpunit That is standalone and will all work out of the box with

cake Phpunit.Phpunit install

It has no dependencies outside of CakePHP itself. No composer, no pear no other 3rdparty issues.

If you do have one of those dependencies available, use that one, though.


Note: As of now the pear channel has been shut down and as such there is only the composer solution to it now. (See other answer)

mark
  • 21,691
  • 3
  • 49
  • 71
  • From which exactly directory have I to run this command, because "cake" is not standard command? And which path have I to add to system_path this command to work from everywhere? – jekahm Mar 12 '14 at 11:10
  • Yes, it works without modifications to system paths. But you need to have your cake console working (which is kind of a default for using CakePHP anyway). See the docs on how to get the basic console working. Usually, all you need to do is add PHP to your system path and use `.\Console\cake [command]`. – mark Mar 12 '14 at 11:26
  • Ok, I did such steps: 1. According to official instruction I've created folder called Phpunit in app/Plugin and copied all plugin files there 2. Then I've add to Windows System Variable "Path" link to where cake.bat is ([path_to_project]\lib\Cake\Console\) 3. Then tried to run this command "cake Phpunit.Phpunit install", but got an error "Plugin Phpunit could not be found" I even don't know what the problem is? Can you help me with this one? – jekahm Mar 12 '14 at 11:49
  • You forgot to include the plugin via CakePlugin::loadAll() etc. You seriously need to upgrade your reading skills as this is all part of the documentation there in the readme as well as part of the official cakephp docu on how to get plugins working. – mark Mar 12 '14 at 11:51
  • cakephp-phpunit doesn't seem to work any more now that http://pear.phpunit.de has been retired - https://github.com/sebastianbergmann/phpunit/wiki/End-of-Life-for-PEAR-Installation-Method – James Ludlow Jan 17 '15 at 12:55
  • Yes as of now this is not working anymore since the pear channel has been retired. Go with composer instead now. It does not have to be a global install. you can also just require it locally per app. – mark Jan 17 '15 at 14:25