Jump to content
Larry Ullman's Book Forums
Edward

Phpunit, Pear, Selenium

Recommended Posts

Yesterday i experienced the worst day ever, i had to install PEAR, then PHPUnit and lastly Selenium.

 

Well i started out early working through Agile Web Application Development with Yii and PHP. Anyway i got stuck on installing PEAR, then it looked like it installed, and i was working on PHPUnit and that looked like it installed but i was continuously getting errors and fixing errors. After hours and hours of going through online help and getting error after error i got to the point at which there was no more help. I was completely stressed out, i had been working on this for around 5 hours, i had a major headache. I don't know about PEARS, but this was driving me Banana's. I decided after a short break that the best thing would be to reinstall install XAMPP completely, so i downloaded there most up to date version. Finally after i got that installed, i found that PEAR and PHPUnit were already all setup, i was like whall this is just amazing, i spend almost 6 hours messing around and then it all works in one go with the new XAMPP. Well regardless of what happened i did feel satisfied when i finally got it installed after all that time spent.

 

Okay for those of you working through Yii, i have a question, im on page.70 (Agile Web Application Development with Yii and PHP), using PHPUnit to run a test on a ProjectTest.php

 

in command prompt we need to type in

 

% cd Webroot/protected/tests

% phpunit unit/ProjectTest.php in

 

after running this im getting an error

 

Parse error: syntax error, unexpected T_VARIABLE C:\xampp\htdocs\yii\trackstar\protected\tests\unit\ProjectTest.php on line 8

 

here is a copy of ProjectTest.php

 

<?php
class ProjectTest extends CDbTestCase
{
public function testCRUD()
{
 //Create a new project
	$newProject=new Project
		$newProjectName = 'Test Project 1';	 // Line 8
	$newProject->setAttributes(
	 array(
			'name'=> $newProjectName,
						'description' => 'Test project number one',
						'create_time' => '2010-01-01 00:00:00',
						'create_user_id' => 1,
						'update_time' => '2010-01-01 00:00:00',
						'update_user_id' => 1,
			  )
	 );
	 $this->assertTrue($newProject->save(false));				  
}
}

 

Do you know what the problem is here?

Share this post


Link to post
Share on other sites

That has done the trick, in the book they just used

 

$newProject=new Project;

 

So i missed out the semi colon. Well either way you can put Project or Project() they both do the same thing. Thanks Paul well spotted.

Share this post


Link to post
Share on other sites

I think your error is actually on line 7, but PHP doesn't notice until it hits the semi-colon on line 8.

 

I think line 7 should be:

$newProject=new Project();

 

Are you using Yii or any other kind of framework for your projects?

Share this post


Link to post
Share on other sites

No, I'm not using any frameworks. And I mostly code in the procedural style and hardly ever do any OOP. Right now I'm working with JSP pages, which is new to me. I wish there were better documentation for JSP. I've been kind of spoiled by PHP's documentation. And of course, Larry hasn't written a book on JSP to de-mystify it!

Share this post


Link to post
Share on other sites

Hmmm...a book on JSP...

 

Actually, I did a wee bit of JSP some years ago, integrating a browser detection tool that required JSP into a PHP-based site. It wasn't pretty, but I got it to work. Good luck, Paul!

Share this post


Link to post
Share on other sites

I think everyone would love to see you write a book on a fully developed website using oop code. There are also only two Yii Framework books available right now, I'm sure if you did one it would be a big hit. Even making a full working site using oop code intergrating into Yii. :rolleyes:

Share this post


Link to post
Share on other sites

That would be awesome. It would be good to consider a bringing it all together OOP book, as there are many books about how OOP works but not the full blown design in a website.

Share this post


Link to post
Share on other sites

I would disagree, a book on OOP can't teach Yii as well, it would be massive, just as a book on Yii can't teach OOP for the same reason and that you wouldn't be able to even get into Yii until you'd read a significant number of pages on OOP. :)

Share this post


Link to post
Share on other sites

Well, my PHP 5 Advanced book discusses OOP, and when I write the 3rd edition (starting next month), I'll expand that coverage.

 

I wouldn't expect that my Yii book would teach OOP, but I imagine I'd have a chapter introducing the core concepts of OOP. You can actually use Yii without much OOP training because the hardest part--designing classes--is done by the framework.

Share this post


Link to post
Share on other sites

It's okay what you've got is fine, there is enough OOP in PHP 5 Advanced for us to be able to work the rest out ourselves. Learning Yii also drastically helps us improve our knowledge and understanding on the implementations of OOP. Hope you enjoyed your weekend, happy to be back here for more posts.

Share this post


Link to post
Share on other sites

I'm sorry but i'm not writing to help you with your questions, however i wanna know how the hell did you make phpunit work, i've spent like 4 days trying to do so but i coundnt, i've this link on stack over flow as i posted a question thier, you can get the details if you decided to help, link: http://stackoverflow.com/questions/10034966/i-want-to-link-xampp-1-7-7-to-the-php-cli, the title of the question sounds different from what i'm asking but that how it started,

thank you for reading this,

Mohamad

Share this post


Link to post
Share on other sites

I went through a lot of online help which ended up not working, so i decided to call it quits and just completely reinstall a new version of XAMMP. After the installation phpunit worked out fine. I thought with that Jeffrey Winesett book that some of the phpunit testing was quite trival, and the application could of just been tested the usual way we do by simple debugging, so be quite honest phpunit seemed a little over the top. Much of the debugging work comes is all about a good level of common sense.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×