News Feed
Jobs Feed
Sections




News Archive
feed this:

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

DZone.com:
PHPUnit vs. Phake cheatsheet
April 19, 2013 @ 09:53:45

On DZone.com today Giorgio Sironi has posted a "cheat sheet" to help you correlate the functionality of two PHP unit testing tools - PHPUnit vs Phake (for mocking objects).

Benjamin Eberlei introduced me to Phake with his recent article: it is a Composer-ready PHP library that integrates easily with PHPUnit and provides an independent Test Doubles framework, capable of producing Stubs, Mocks, and Spies. The syntax and object model reminds me of Mockito, the Java Test Double framework from the authors of Growing Object-Oriented Software. I like tools that do one thing and do it well, and after experimenting with Phake I'm using it on all new code.

He compares the two tools on a few different pieces of functionality including creating stubs, mocks and spies. Sample code is included for both sides. It's not a detailed guide by any means, but it can give you a better picture of how the two compare.

0 comments voice your opinion now!
phpunit phake mock stub unittest spies compare cheetsheet

Link: http://css.dzone.com/articles/phpunit-vs-phake-cheatsheet

QaFoo.com:
Mocking with Phake
March 13, 2013 @ 12:53:26

On the QaFoo blog today there's a new tutorial posted showing you how to make unit test mocks with Phake, a testing tool that works a bit differently that other options (PHPUnit's own mocking and Mockery).

The use of Mock and Stub Objects is an important skill to learn when using Test Driven Development (TDD). Mock objects allow you to replace dependencies of an object with lookalikes, much like crash test dummies are used during automobile safety tests so humans aren't harmed. [...] Using Mocks in PHPUnit tests means using the built-in MockObjects library for quite some years. In the last years two contenders emerged that can be used as optional dependencies in PHPUnit. [...] This blog post introduces Phake, because it works quite differently than both PHPUnit Mock Objects and Mockery.

They include a code example of how to create mocks with Phake, showing it's different approach to defining the mocked methods. They explain each part of the code, detailing the use of the "when", "thenReturn" and "verify" methods. You can find out more about Phake and see other examples in the project's documentation.

0 comments voice your opinion now!
mocking unittest phake library tutorial introduction


Mike Lively's Blog:
Pear Channel set up for Phake
December 31, 2010 @ 13:30:42

Mike Lively has a new post about a PEAR channel he's set up for his Phake mocking tool on his digitalsandwich.com domain.

For those that may not have caught my first post on the subject, Phake is a mock framework that I announced a couple of days ago in Introducing Phake Mocking Framework. It was recommended in the comments that I get it on a pear channel somewhere, which is something I have wanted to do but hadn't had a reason to do until this week. Well, now there is an official Digital Sandwich Pear Channel that is hosting Phake.

Discover the channel with the PEAR installer and run the install with the path provided. He notes that the release is alpha because of the lack of documentation but, despite this, the API is stable. Also, you'll need to be using PHP 5.2+ to use the tool.

0 comments voice your opinion now!
phake mock testing framework unittest pear channel


Mike Lively's Blog:
Introducing Phake Mocking Framework
December 29, 2010 @ 08:40:27

Mike Lively has a new post to his blog today looking at a mocking framework he's developed to work hand in hand with PHPUnit to make mocking easier and more robust.

I have used PHPUnit heavily now for the last 4 years. As anyone that is heavily involved in writing Unit Tests knows, test doubles (commonly referred to as mock objects) are a necessary part of your toolbox. The mocking options that we used to have for PHP unit testing have traditionally been fairly limited and most all of them in some form or another were ports of JMock. The way PHP operates as well as some decisions made to more closely emulate how JMock does things lead to functionality in the existing mock library for PHPUnit that for some are a hassle.

To help eliminate this hassle, he create the Phake mocking framework - a tool that comes at mocking a different way than the normal PHPUnit procedures. He includes some sample code for a class to test, a simple stub for getting a value and how to use it in a basic test. By calling a "Phake::mock()" on the class to make an object, you can call the method and run a "verify()" to ensure that the results are correct. He talks about some other options that the mocking allows too like calling a "no interaction" method on a mock and argument capturing.

0 comments voice your opinion now!
mock framework unittest phake github phpunit


Pavel Shevaev's Blog:
taskman yet another Ant alternative
October 14, 2010 @ 09:56:39

Pavel Shevaev has put together what he calls "yet another Ant alternative" - a tool written in PHP to create project related tasks in a style that matches the Ant and rake methods.

There is a lib-taskman project on the google code hosting where you can find the full documentation, sources and latest releases. It's probably not that elegant as rake but if you want to stick to PHP and have Ant-alike functionality without any XML programming then taskman may turn out to be handy. taskman is very simple to use, it requires only one include, all its code resides in one PHP file, and it has no external dependencies.

He includes a basic use example that sets up the build with "task_hello", "task_comma", "task_world" and "task_say" methods that each do some basic output to show the flow of the process. He also gives examples of possible uses for the tasks like database bootstrapping, auto-code generation, project deployment, etc. He also mentions two other PHP-based projects that do similar things - pake and Phake.

0 comments voice your opinion now!
rake build tool taskman ant alternative phake pake



Community Events











Don't see your event here?
Let us know!


opinion symfony2 application code overview podcast language hhvm install facebook example package composer hack component introduction unittest release security framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework