Jump to content


Photo

Need to add a phpunit section to docs

staff response

  • Please log in to reply
5 replies to this topic

#1 that0n3guy

that0n3guy

    Advanced Member

  • Premium Members
  • PipPipPip
  • 276 posts

Posted 26 August 2014 - 12:44 PM

I found this: http://www.x2engine....s-with-phpunit/  but the video seems to be broken.

 

Since this: End of Life for PEAR Installaation, running PHPunit was kind of tricky at first.  Here is how I did it: http://peterjolson.c...i-and-teamcity/

 

UPDATE: my db credentials weren't right on my teamcity server, this is fixed: I'm not able to run the db tests as I get an error "CDbException: CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2002] No such file or directory"...  Any help on this?



#2 X2Raymond

X2Raymond

    Advanced Member

  • Administrators
  • 972 posts
  • LocationSanta Cruz, CA

Posted 26 August 2014 - 02:18 PM

Have you seen the section in the wiki? It covers general unit and functional testing in X2: http://wiki.x2engine...ng_With_PHPUnit There are also a handful of other references from the PHPUnit and Yii Framework docs, but this was compiled before the end of life for PEAR installations.

 

In order to execute the unit tests, you will need to copy the installation files back into your X2 web root, and install again, this time with your testing database credentials, and enabling the 'Testing Database' checkbox.

 

Have you been able to execute the tests using phpunit from the command line?



#3 that0n3guy

that0n3guy

    Advanced Member

  • Premium Members
  • PipPipPip
  • 276 posts

Posted 28 August 2014 - 06:21 AM

Yes, I saw the wiki.   I got it running.  But the docs should be updated.  My blog post above shows how I did it.

 

I've got it running using our Teamcity (continuous integration server) server and from my local command line.  Are you guys using a CI server for your tests?



#4 X2Raymond

X2Raymond

    Advanced Member

  • Administrators
  • 972 posts
  • LocationSanta Cruz, CA

Posted 28 August 2014 - 09:19 AM

Yes, I agree completely. Great, I'll look into it, I haven't heard of Teamcity before, it looks pretty cool though. The other CI server I have been looking into is Jenkins (formerly Hudson), but it would be interesting to see if anyone had any experience with this in a PHP environment. Currently we're not using CI, but we automate running our unit and functional tests in all three editions with a script. I will be investigating Teamcity more, specifically looking for a method that would allow us to continue testing multiple editions at once.



#5 that0n3guy

that0n3guy

    Advanced Member

  • Premium Members
  • PipPipPip
  • 276 posts

Posted 28 August 2014 - 09:44 AM

Yeah.  I choose teamcity over jenkins for a couple reasons:

 

- Jenkins is supposed to be a pain to get going, though it does have lots of plugins.

- we use youtrack for issue tracking (another jetbrainz product), it integrates with that.

- we use phpstorm for coding (another jetbrainz product)... we sort of like jetbrainz products

- it is to be easy to setup.

- Jenkins doesn't look as pretty (I know, I know :P )

 

I posted how I set mine up: http://peterjolson.c...s-solaris-zone/

and 

http://peterjolson.com/installing-teamcityyoutrack-in-a-tomcat-container-with-tomcat-virtual-host-smartos-vm/

(using solaris... linux would be very similar).

 

I'm probably going to be moving the whole setup to a docker-ized (docker: https://www.docker.com/) setup instead.  Where my my teamcity build agent (the "thing" that teamcity uses to run actual builds/test/commands/etc...) is in linux and will run tests within the docker containers (you could use different containers for different php versions/database version&types etc...).

 

Getting teamcity to run your different versions would be as easy as having teamcity pull (using git?) your different branches... or have it download a zip and extract it.  

 

Take a look at this screenshot where I test different branches of my repo: http://screencast.com/t/RPR0X4oBzxA

 

Lastly... kinda random, but here is the script I run before every unit testing (so I can present the tested site to the web or private intranet): https://github.com/t...-teamcity-agent  It just creates a nginx virtual host and reload nginx.  Built for solaris again... but easy to modify for linux.



#6 X2Raymond

X2Raymond

    Advanced Member

  • Administrators
  • 972 posts
  • LocationSanta Cruz, CA

Posted 28 August 2014 - 04:28 PM

Excellent, thank you for your input, this gives me a good place to start looking further into TeamCity. I've been interested in exploring some CI products, this could be a good fit.

 

Running the builds in Docker containers sounds great, that would be the perfect way to automate testing over multiple environments! Please let me know how this goes.







Also tagged with one or more of these keywords: staff response

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users