Archive for December, 2007

Unit Testing PHP

Saturday, December 29th, 2007

A while back I was working on a site, and as I was writing the back end and making sure that it works properly I thought to myself “If .NET has nunit, and Java has junit, does PHP have phpunit, or something similar?” After some digging I found the answer. The answer I found was yes! In addition to finding unit frame works for PHP I also found some for other languages like ada, haskell and so on:

aunit - for Ada
hunit - for Haskell
ant-junit - Apache Ant’s optional tasks depending on junit
dbunit - DBUnit is a JUnit extension targeted for database-driven pr
ojects.
tagunit - for testing custom JSP tags
xmlunit - for XML
and so on. If you want a complete list, on the command prompt, if you’re using Gentoo, just type:

# emerge –search unit | less

and have fun!

For PHP there are a few different ones:

dev-php4/phpunit
dev-php5/phpunit
dev-php/simpletest

At the time of writing this, dev-php4/phpunit is masked, but the version of phpunit for PHP 5 is not. I chose simpletest because I didn’t have to unmask any packages in order to install it.

# emerge simpletest

BAM! Done!

(more…)

Enabling Auto Login in Windows XP and Vista

Saturday, December 22nd, 2007

Some people don’t like to enter a user name or password to use their computer. For others it’s pointless as they are the only one using the computer. To disable the Login Prompt follow the steps below.

  1. Start->Run

  2. Un-check the box that says “Users must enter a user name and password to use this computer”

That’s it. You no longer have to enter a user name or password to use the computer.

Server Upgrade

Monday, December 17th, 2007

About two months ago I received word from my Hosting provider that they will be performing upgrades to their server. After two months, they finally got around to me. I have scheduled the upgrade for December 31 at 00:00, so that’s 12:00 am, CST.

I can’t begin to tell you how happy this makes me. When I signed up for them over a year ago, I was only able to use PHP 4, and MySQL 4. On their Windows Server, they were still using .NET 1.1. This was rather frustrating as when I signed up they just said “PHP, MySQL, and ASP.NET” It wasn’t until later they changed it to reflect the actual version.

So by the time the new year starts, I will be able to use PHP 5 and MySQL 5. Hopefully, they will upgrade .NET 2.0.

I’m praying that there won’t be any kinks with my blog or anything else on my site. If there is, you know what I’m going to be doing for the first part of 2008!

Changing Images with Java Script

Monday, December 17th, 2007

While working on a site, I decided to add some Java Script to the menu bar so the site would be more interactive. I wanted the image to change so it gave the appearance as if the user is actually clicking on the button. Being a bit rusty on my Java Script I had to look up how one is supposed to reference an object on the page.

I came across a well written tutorial on how to change the images, but there was one minor problem. The script didn’t work. Perhaps it’s my web browser, or maybe I’m doing something wrong. When I look at the code itself it doesn’t make sense to me. What I kept finding over and over again was this:

document[image_name].src = …

The problem with the above statement, is that you’re trying to find the image by referencing the document array with the image name. That is an array of documents, not an array of images. I played around with this at first thinking that maybe Java Script is a bit funny. The error console in Firefox kept telling me that I was trying to set the property of an object that did not have that property. Further investigation revealed that I was correct in my thinking.

The correct way in setting the source of an image object is actually:

document.images[image_name].src = …

The best way to change the image when the cursor is over the image is to write a function that can be reused:

function(mouse_over(image_name, image_source)
{
document.images[image_name].src = image_source
}

After including the code in your page, you can use the function like so: