Skip to content

Instantly share code, notes, and snippets.

@isidromerayo
Created January 24, 2012 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isidromerayo/1671392 to your computer and use it in GitHub Desktop.
Save isidromerayo/1671392 to your computer and use it in GitHub Desktop.
First test with Mockito - Point Of Sale - Hola TDD
@Test
public void onBarcode_search_catalog() throws Exception {
Catalog catalog = mock(Catalog.class);
PointOfSale pointOfSale = new PointOfSale(catalog);
pointOfSale.onBarcode("123");
verify(catalog).search("123");
}
<?php
/**
* @test
*/
public function onBarcode_search_catalog()
{
$catalog = m::mock('Catalog');
$pointOfSale = new PointOfSale($catalog);
// verify(catalog).search("123");
$catalog->shouldReceive('search')->once()->with('123');
$pointOfSale->onBarcode('123');
}
<?php
/**
* @test
*/
public function onBarcode_search_catalog()
{
$catalog = Phake::mock('Catalog');
$pointOfSale = new PointOfSale($catalog);
$pointOfSale->onBarcode('123');
// verify(catalog).search("123");
Phake::verify($catalog)->search('123');
}
<?php
/**
* @test
*/
public function onBarcode_search_catalog()
{
$catalog = Phockito::mock('Catalog');
$pointOfSale = new PointOfSale($catalog);
$pointOfSale->onBarcode('123');
// verify(catalog).search("123");
Phockito::verify($catalog)->search('123');
}
<?php
/**
* @test
*/
public function onBarcode_search_catalog()
{
$catalog = $this->getMock('Catalog');
$pointOfSale = new PointOfSale($catalog);
// verify(catalog).search("123");
$catalog->expects($this->once())->method('search')->with('123');
$pointOfSale->onBarcode('123');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment