Jump to content



Photo

Phpunit, Pear, Selenium


  • Please log in to reply
14 replies to this topic

#1 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 1,127 posts

Posted 7 February 2012 - 12:51 PM

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?
  • 0

#2 Paul Swanson

Paul Swanson

    Excellent Advisor

  • Members
  • PipPipPip
  • 163 posts
  • LocationPortland, OR, USA

Posted 7 February 2012 - 4:26 PM

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();

  • 1

#3 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 1,127 posts

Posted 8 February 2012 - 8:37 AM

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.
  • 0

#4 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 1,127 posts

Posted 8 February 2012 - 8:38 AM

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?
  • 0

#5 Paul Swanson

Paul Swanson

    Excellent Advisor

  • Members
  • PipPipPip
  • 163 posts
  • LocationPortland, OR, USA

Posted 8 February 2012 - 11:16 AM

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!
  • 0

#6 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,845 posts
  • LocationState College, PA (USA)

Posted 8 February 2012 - 11:58 AM

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!
  • 0

#7 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 1,127 posts

Posted 9 February 2012 - 2:22 PM

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:
  • 0

#8 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,845 posts
  • LocationState College, PA (USA)

Posted 10 February 2012 - 8:43 AM

Thanks, Edward. I am planning/hoping to write a book on Yii this year.
  • 1

#9 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 1,127 posts

Posted 10 February 2012 - 12:53 PM

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.
  • 0

#10 Jonathon

Jonathon

    Advanced Member

  • Members
  • PipPipPip
  • 1,023 posts

Posted 10 February 2012 - 4:04 PM

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. :)
  • 0

#11 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 1,127 posts

Posted 10 February 2012 - 4:09 PM

I meant a separate book on OOP not including Yii. Don't forget also that some pick up things faster than others!
  • 0

#12 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,845 posts
  • LocationState College, PA (USA)

Posted 10 February 2012 - 5:16 PM

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.
  • 0

#13 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 1,127 posts

Posted 13 February 2012 - 12:08 AM

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.
  • 0

#14 Mohamad

Mohamad

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 7 April 2012 - 1:54 AM

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...-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
  • 0

#15 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 1,127 posts

Posted 9 April 2012 - 8:55 AM

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.
  • 0