RESTful client-server with MVC Design Pattern

Few months ago I’ve created a Service Oriented Architecture from scratch using the MVC paradigm.
The API is based on three parameters to demonstrate you can create your own with as many parameters you prefer*.

http://restful_client-server/category/keyword/pub_year

where

  1. {category}
    The value ‘book’ is the only available for this parameter

  2. {keyword}
    Any string, any keyword for the book search

  3. {pub_year}
    The published year in the following format 0000

For example, with the following request you’ll get all the books with “RESTful” in the title and with publish year “2014”

http://restful_client-server/book/RESTful/2014

Continue reading

Advertisements

PHPUnit – “Stubbing a method call to return the value from a map”

phpunit

The PHPUnit method returnValueMap() made me think a bit about how it works.

The following definition, taken from the official PHPUnit documentation, is not too verbose and I had to do few searches and few tests on my own before coming to an acceptable conclusion.

Sometimes a stubbed method should return different values depending on a predefined list of arguments. You can use returnValueMap() to create a map that associates arguments with corresponding return values. See Example 10.6 for an example.
(source PHPUnit Manual Test Doubles Stubs Example 10.6 )

Continue reading