Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Chris Hartjes:
5 Minute TDD
Aug 17, 2012 @ 14:10:05

Chris Hartjes, a big proponent of testing (unit and otherwise) in the PHP community has put together a screencast to show just how easy it can be to get started with TDD (test-driven development) in PHP.

I want to talk about test driven development and show you in five minutes how to set up.

His example uses a common problem - the FizzBuzz test - and shows how to write a simple test to check the output of his "process()" method that it matches his expected results. It's a simple example, but a great (realtime) primer to how the TDD process works.

tagged: tdd testdriven video tutorial screencast fizzbuzz

Link:

Gonzalo Ayuso's Blog:
Runtime Classes. A experiment with PHP and Object Oriented Programming
Aug 08, 2011 @ 14:17:05

Gonzalo Ayuso has put together an experiment related to the current OOP structure of PHP - a test working with runtime classes, a structure generated entirely when the script is executed and not predefined in the file.

Last week I was thinking about creation of a new type of classes. PHP classes but created dynamically at run time. When this idea was running through my head I read the following article and I wanted to write something similar. Warning: Probably that it is something totally useless, but I wanted to create a working prototype (and it was fun to do it).

His class is pretty basic - a "Human" object that echoes a "hello world" sort of message via a "hello()" method. He creates the classes inside of different test methods to ensure that his assertions are true. The tests check basic output of the "hello()" method, calling undefined methods, testing inheritance and a test creating and evaluating a dynamic function.

For something more complex, he creates a dynamic class that solves the FizzBuzz kat, a popular programming puzzle. You can find the full code for this and his other examples on github.

tagged: runtime class experiment objectoriented oop fizzbuzz

Link:


Trending Topics: