Example:
class Math { public function add($arg1, $arg2) { if (!is_numeric($arg1) || !is_numeric($arg2)) { throw new Exception('cannot add non numerics'); } return $arg1 + $arg2; } } class Person { public function getTotalItems(Math $math, $shoes, $shirts) { return $math->add($shoes, $shirts); } }
Mock Unit Test:
public function getTotalItemsTest() { $mockMath = $this->getMockBuilder('Math') ->setMethods(array('add')) ->getMock(); $mockMath->expects($this->once()) ->method('add') ->with($this->isType('numeric'), $this->isType('numeric')) ->will($this->returnCallback(function ($arg1, $arg2) { return $arg1 + $arg2; })); $total = $person->getTotalItems($mockMath, 2, 3); $this->assertEquals(5, $total); }
Stub Unit Test:
public function getTotalItemsTest() { $stubMath = $this->getMockBuilder('Math') ->setMethods(array('add')) ->getMock(); $stubMath->expects($this->any()) ->method('add') ->will($this->returnValue(5)); $total = $person->getTotalItems($stubMath, 2, 3); $this->assertEquals(5, $total); }
This is not the best example but you get the groove? When you mock an object, you set an "expectation" for the object method you are mocking. In the case above, we are checking that add() only accepts numerical inputs. Usually, a dead give away is we are using with() to set our expectation. In contrast to a stub, we are just returning straight the result.
Note that the callback for a mock does not matter. I just use it for verbosity.
10 comments:
Sergei , October 22, 1970 Born in Christian Louboutin Bois Dore Moscow State Ozherelye. Perhaps influenced by Cheap LV Handbags their parents worship warrior army, join the army in cheap jordans 1989, and into the elite airborne military service. 1991, by the influence of the Soviet Union, the uggs on sale Russian christian louboutin army general lack of funds, a large number ugg australia of Air Jordan 11 Gamma Blue soldiers seeking veterans, but under extremely difficult conditions still dedicated, praise superiors, and soon was sent to the famous christian louboutin shoes Ryazan Higher ugg Airborne Command School studies. After graduating in 1994, entered the famous Pskov 76th Guards Airborne discount christian louboutin Division, served as discount nike jordans the reconnaissance platoon, reconnaissance ugg soldes deputy company commander, company commander, battalion airborne regiment scouting director and other duties.From 2000 to Cheap Louis Vuitton Handbags 2004, where the forces have repeatedly ordered war with Chechen militants. Because of their opponents in order to form the squad activity and haunted impermanence, the Russians had to ugg boots mobilize elite troops set up large uggs outlet number of small units, "a Discount Louis Vuitton small wholesale jordan shoes play small" Implementation siege. commanding troops in Chechnya, Christian Louboutin Daffodile Ingushetia and other places over the mountains, to track the militants fled. Discount LV Handbags Although the militants were extremely vigilant, but as long as the task has never had outsmarted.August 8, 2008, Georgia suddenly invade South Ossetia (Russian peacekeepers stationed ugg pas cher there), the Russian military to respond quickly, including including the 76th Guards Airborne Division, more than christian louboutin remise 50% 3,000 people were immediately delivered to the pro-Russian Abkhazia, Georgia cheap nike jordan shoes Army contain two infantry brigades, effectively coordinate the cheap christian louboutin direction of the Russian Bags Louis Vuitton troops in South Ossetia.
2015-09-16 zhengjx
nike trainers
toms outlet
celine handbags
michael kors outlet
Hollister UK Clothing Store
Louis Vuitton Outlet Discount Handbags
Cheap Louis Vuitton Handbags Luggage Bags Sale
cheap jordans
hollister uk
michael kors bags
ugg boots sale
Gucci Outlet Online 80% OFF
ugg australia
michael kors outlet
Mont Blanc Pens For Sale
Michael Kors Outlet Online 70% Off Handbags
Ralph Lauren UK Sale Polo Shirts
Christian Louboutin Outlet For Women
ugg boots
Louis Vuitton Outlet Authentic Handbags Discount
michael kors handbags
Louis Vuitton Handbags Outlet On Sale
Louis Vuitton Outlet Purses and Handbags For Sale
canada goose
hermes birkin
New Jordans Cheap For Sale
Abercrombie & Fitch Clothing With Big Discount
Coach Factory Outlet Handbags 70% OFF
Lebron 12,11,10 Shoes For Sale
cheap uggs sale
ray ban sunglasses, http://www.raybansunglassesonline.us.com/
nike trainers, http://www.niketrainers.me.uk/
gucci handbags, http://www.guccihandbags-outlet.co.uk/
herve leger, http://www.herveleger.us.com/
timberland boots, http://www.timberlandboots.name/
coach outlet online, http://www.coachoutletonline-store.us.com/
michael kors outlet, http://www.michaelkorsoutletcanada.in.net/
juicy couture outlet, http://www.juicycoutureoutlet.net/
calvin klein underwear, http://www.calvinklein.in.net/
ray ban sunglasses, http://www.raybansunglass.us.com/
prada outlet, http://www.pradaoutlet.us/
lululemon outlet, http://www.lululemonoutletstore.in.net/
tory burch shoes, http://www.toryburchshoesoutlet.com/
michael kors outlet, http://www.michaelkorsoutlet.org.uk/
replica watches, http://www.replicawatchesforsale.us.com/
pandora jewelry, http://www.pandorajewelryoutlet.us.com/
nfl jerseys wholesale, http://www.nfljerseys-wholesale.us.com/
michael kors outlet, http://www.michaelkorsoutletonlinstore.us.com/
oakley outlet, http://www.oakleyoutlet.in.net/
oakley sunglasses, http://www.oakleysunglasses-outlet.us.com/
michael kors bags, http://www.michaelkorsbags.uk/
ray ban sunglasses, http://www.ray-bansunglasses.eu.com/
oakley sunglasses, http://www.oakley.in.net/
air max 2015, http://www.airmax2015.in.net/
the north face uk, http://www.thenorthfaces.org.uk/
swarovski outlet, http://www.swarovski-outlet.co.uk/
pandora jewelry, http://www.pandora.eu.com/
chanel handbags, http://www.chanelhandbags-outlet.co.uk/
1002maoqiuyun
chenlina20151127
chanel handbags
air force 1
christian louboutin shoes
pandora outlet
the north face outlet
cheap air max
oakley sunglasses
jordan retro
nike free runs
uggs outlet
oakley outlet
jordans for sale
ugg boots outlet
christian louboutin outlet
the north face outlet
louis vuitton purses
louis vuitton outlet
jordan concords
louis vuitton outlet
louis vuitton outlet
ugg boots
uggs on sale
ugg boots
louis vuitton
louboutin pas cher
christian louboutin
coach factory outlet
gucci outlet
ugg slippers
running shoes
swarovski outlet
coach outlet store online
official coach factory outlet
uggs outlet
air jordans
canada goose outlet
cheap air jordans
mont blanc pens
mulberry handbags
louis vuitton bags
as
moncler, moncler outlet, marc jacobs, moncler, hollister, montre pas cher, vans, ray ban, replica watches, pandora charms, louis vuitton, supra shoes, sac louis vuitton pas cher, pandora jewelry, swarovski, pandora charms, moncler, bottes ugg, barbour, canada goose, ugg,uggs,uggs canada, louis vuitton, doke gabbana outlet, converse, louis vuitton, lancel, louis vuitton, hollister, moncler, pandora jewelry, doudoune canada goose, juicy couture outlet, nike air max, converse outlet, barbour jackets, moncler, ugg,ugg australia,ugg italia, links of london, moncler, gucci, canada goose outlet, canada goose, canada goose outlet, coach outlet, canada goose uk, ugg boots uk, canada goose, juicy couture outlet, ugg pas cher, wedding dresses, canada goose
chenlina20160127
michael kors outlet
burberry outlet
chanel handbags
ralph lauren outlet
cheap jordans
beats solo
ugg boots sale
louis vuitton outlet
true religion outlet
gucci handbags
cheap oakley sunglasses
louboutin
air max 95
chanel outlet
mihchael kors outlet online
jordan 11 concord
louis vuitton handbags
gucci outlet
kate spade
ray ban sunglasses
toms shoes
uggs outlet
ray ban sunglasses
nike air max
michael kors handbags
coach outlet store online
oakley sunglasses
coach factory outlet
louis vuitton purses
canada goose jackets
louis vuitton
replica watches
michael kors outlet
louis vuitton outlet stores
ray ban outlet store
marc jacobs handbags
louis vuitton
louboutin pas cher
tiffany and co
cheap oakley sunglasses
as
Quikcbooks Support Phone Number
Quikcbooks Support Number
Quikcbooks Support Phone Number
Quikcbooks Tech Support Number
Quikcbooks Technical Support Number
Quikcbooks Tech Support Phone Number
Quikcbooks Technical Support Phone Number
Quikcbooks Helpdesk Phone Number
Quikcbooks Customer Service Phone Number
Quikcbooks Customer Service Number
Quikcbooks Customer Support Number
Quicken Support Phone Number
Quicken Support Number
Quicken Support Phone Number
Quicken Tech Support Number
Quicken Technical Support Number
Quicken Tech Support Phone Number
Quicken Technical Support Phone Number
Quicken Helpdesk Phone Number
Quicken Customer Service Phone Number
Quicken Customer Service Number
Quicken Customer Support Number
Sage Support Phone Number
Sage Support Number
Sage Support Phone Number
SageTech Support Number
Sage Technical Support Number
Sage Tech Support Phone Number
Sage Technical Support Phone Number
Sage Helpdesk Phone Number
Sage Customer Service Phone Number
Sage Customer Service Number
Sage Customer Support Number
qzz0710
ray ban sunglasses
air jordan 3
stuart weitzman shoes
tory burch outlet
fitflops sale
kd 10 elite
bulls jerseys
ralph lauren polo shirts
ugg outlets
burberry outlet
تركيب جبس بورد بالرياض شركة تركيب جبس بورد بالرياض افضل شركات تركيب جبس بورد الرياض معلم جبس بورد
معلم دهانات بالرياض معلم دهانات بالرياض فني دهانات بالرياض مقاول دهانات بالرياض
فني تركيب ورق جدران بالرياض فني تركيب ورق جدران بالرياض معلم تركيب ورق حائط بالرياض شركة تركيب ورق جدران في الرياض
شركة مكافحة الحمام بالرياض شركة تركيب طارد الحمام بالرياض افضل شركة طارد الحمام بالرياض
ارخص نقل اثاث بجدة ارخص نقل اثاث بجدة ارخص شركة نقل عفش بجدة ارقام شركات نقل العفش جدة
نقل عفش من الدمام الى الاردن شركة نقل عفش من الدمام الى الاردن افضل شركة شحن عفش من الدمام الى الاردن
شركة مكافحة الحمام بالرياض
Appreciate yourr blog post
Post a Comment