10

Current, I installed phpunit. i use OS win 10. I think i installed new version from https://phpunit.de/ (current version 5.6, beta 5.7). But when check version with command line, it version 3.7. My version PHP Unit

i read these post: How do I update phpunit?. But i can't understand. Help me !!! :(

Matteo
  • 37,680
  • 11
  • 100
  • 115
Thanh Dong
  • 101
  • 1
  • 1
  • 6

5 Answers5

26

Just download the latest version and replace the old one. It is provided from the phpunit homepage.

$ wget https://phar.phpunit.de/phpunit.phar

$ chmod +x phpunit.phar

$ sudo mv phpunit.phar /usr/local/bin/phpunit

You are in the latest version. To check version you can use

$ phpunit --check-version
Shiro
  • 7,344
  • 8
  • 46
  • 80
  • Thanks. Solved my problem :) – Oniya Daniel Sep 15 '17 at 10:26
  • This does not provide the latest version, today it gave me 6.4.2 however 6.4.3 (or more) is available elsewhere. – ajthinking Oct 17 '17 at 06:23
  • you can access to `https://phar.phpunit.de/`, it actually shows the latest updated. and I check on the author github https://github.com/sebastianbergmann/phpunit/commit/06b28548fd2b4a20c3cd6e247dc86331a7d4db13, now he is preparing to released. If u want unreleased version, u always can build yourselves. – Shiro Oct 17 '17 at 06:44
  • The code `whereis phpunit` before `sudo mv phpunit.phar /usr/local/bin/phpunit` helps a lot – Xolani May 16 '19 at 16:01
7

If you have installed PHPUnit globally with the PHP Archive (PHAR) procedure, you can simply run:

phpunit --self-update

Note that:

The openssl extension is required for using the --self-update feature of the PHAR.

More info in the doc.

Hope this help

Matteo
  • 37,680
  • 11
  • 100
  • 115
3

It looks like you have PHPUnit 3.7 installed globally and on your PATH. Either replace your global phpunit with the PHAR you downloaded or explicitly execute the latter.

Sebastian Bergmann
  • 7,837
  • 1
  • 27
  • 35
  • thank you answer my question. :D. But i think i will use version PHPUnit of composer. it simple and great !! – Thanh Dong Nov 21 '16 at 05:57
2

There are two different things update and upgrade. If you type

phpunit

it will show you all commands available. If you see in the end it shows

--self-update       Update PHPUnit to the latest version within the same
                    release series.

--self-upgrade      Upgrade PHPUnit to the latest version.

Try what you need.

RN Kushwaha
  • 2,081
  • 3
  • 29
  • 40
2

You can download as per php version and install it as globally:

wget -O phpunit https://phar.phpunit.de/phpunit-7.phar

chmod +x phpunit

To check version you can use:

./phpunit --version

To set phpUnit as globally you can use:

sudo mv phpunit /usr/local/bin/phpunit

To run and test phpunit you can use:

phpunit

PHPUnit 7.3.1 by Sebastian Bergmann and contributors.