Project

General

Profile

Download (3.17 KB) Statistics
| Branch: | Tag: | Revision:
1
HOW TO RUN THE PHPUNIT TESTS IN ECLIPSE
2
============================================
3
Author: Andreas Kohlbecker, 2012
4

    
5

    
6
NOTE: these tests are to be run from within {DRUPAL_ROOT}/sites/*/modules/cdm_dataportal/test/phpunit
7

    
8

    
9
 Install PHPunit
10
----------------------------------------------
11

    
12
in the following we assume that you have installed php5.2 manually according to the
13
guidance given in http://dev.e-taxonomy.eu/trac/wiki/Install_php5.3_to_php5.2_in_parallel
14

    
15

    
16
update PEAR:
17

    
18
	cd /usr/bin/php52
19
	sudo ./pear config-set auto_discover 1
20
	sudo ./pear install phpunit/PHPUnit
21

    
22
 the above should be suficcient,
23
 but in case something is going wrong you also can try :
24

    
25
  	sudo ./pear upgrade pear
26
	sudo ./pear channel-discover pear.phpunit.de
27

    
28
phpUnit should now be installed in /usr/share/php52/pear/PHPUnit
29

    
30
you may also have to install PHP_CodeCoverage:
31

    
32
	sudo ./pear channel-discover components.ez.no
33
	sudo ./pear install phpunit/PHP_CodeCoverage
34
	sudo ./pear install pear.phpunit.de/PHP_CodeCoverage
35

    
36

    
37
and also xdebug:
38

    
39
	sudo ./pecl install xdebug
40

    
41

    
42

    
43
 Adding the PEAR libraries to eclipse
44
----------------------------------------------
45

    
46
based on http://pkp.sfu.ca/wiki/index.php/Configure_Eclipse_for_PHPUnit#Configure_XDebug_Debugger_to_work_with_PHPUnit
47

    
48
 1. First make sure that your project has the correct include and build path.
49
    Right click on your project in the navigator and select "Properties".
50
    Then navigate to the "PHP Include Path" preference page.
51
    Click on the "Libraries" tab, then click "Add Library..."
52
    Click '"Next" ---> "Config" --> (Preferences php/php libraries) "New"
53

    
54
    Enter the library name "PEAR" and add it to the environment.
55
	After returning to the preferences page click the "Add external folder..." button
56
	Find your PEAR folder (usually you find it in your PHP directory, as
57
	in our case of  php5.2 installed manually where it is /usr/share/php52/pear.
58
	In some distributions it is the php folder itseld rather than the PEAR folder
59
	as most PEAR packages (including PHPUnit) are directly installed into /usr/share/php.)
60
	Return to the preferences page and click "Ok"
61

    
62

    
63
 Running phpunit tests in eclipse
64
----------------------------------------------
65

    
66
 what we are now trying to achieve with the eclipse launcher configuration is in principle
67
 to run the following command:
68

    
69
  /usr/bin/php52/php /usr/bin/php52/phpunit --verbose --bootstrap bootstrap.php
70

    
71
therefore we provide the script phpunitRunner.php wich will execute phpUnit.
72
In order to configure it properly you need to supply some environment variables.
73

    
74
  DRUPAL_ROOT - path to the root of your Drupal installation, that is dataportal installation.
75
  XDEBUG_CONFIG - mjust be set to 'idekey=ECLIPSE_DBGP'
76
  SITE_BASE_PATH - set this variable to the base path of the dataportal website you want to use for testing, eg: /flora-malesiana
77

    
78

    
79
Create a new php run configuration wich executes phpunitRunner.php and configure the above named
80
environment variables in the "Environment" tab.
81
In the "PhpScriptArgument" tab set the following:
82

    
83
  	--stderr --configuration ${workspace_loc:/Drupal5/sites/all/modules/cdm_dataportal/test/phpUnit/phpUnit.conf.xml} ${workspace_loc:/Drupal5/sites/all/modules/cdm_dataportal/test/phpUnit/src/}
84

    
85

    
86

    
87

    
(1-1/5)