Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@isidromerayo
isidromerayo / about.md
Created August 17, 2011 12:17 — forked from kinisoftware/about.md
Programming Achievements: How to Level Up as a Developer
@isidromerayo
isidromerayo / PointOfSaleTest.java
Created January 24, 2012 17:37
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");
}
@isidromerayo
isidromerayo / PointOfSale2Test.java
Created January 24, 2012 18:06
Second test with Mockito - Point Of Sale - Hola TDD
@Test
public void onBarcode_search_catalog() throws Exception {
Catalog catalog = mock(Catalog.class);
Screen screen = mock(Screen.class);
PointOfSale pointOfSale = new PointOfSale(catalog, screen);
pointOfSale.onBarcode("123");
verify(catalog).search("123");
}
@isidromerayo
isidromerayo / TemperatureTest_Mockery.php
Created February 6, 2012 18:13
Example temperature webservice
<?php
/**
* @test
*/
public function getsAverageTemperatureFromThreeServiceReadings() {
$service = m::mock('Service');
$service->shouldReceive('readTemp')->times(3)->andReturn(10, 12, 14);
$temperature = new Temperature($service);
$this->assertEquals(12, $temperature->average());
@isidromerayo
isidromerayo / ExceptionsTest.php
Created February 6, 2012 18:22
Phake examples
<?php
public function testProcessSomeDataLogsExceptions() {
$logger = Phake::mock('LOGGER');
$data = Phake::mock('MyData');
$processor = Phake::mock('MyDataProcessor');
Phake::when($processor)->process($data)
->thenThrow(new Exception('My error message!'));
@isidromerayo
isidromerayo / ExceptionsTest.php
Created February 6, 2012 18:25
PHPUnit Mock examples
<?php
/**
* @expectedException RuntimeException
*/
public function testThrowExceptionStub()
{
$stub = $this->getMock('SomeClass');
$stub->expects($this->any())
@isidromerayo
isidromerayo / ExceptionsTest.php
Created February 6, 2012 18:30
Mockery examples
<?php
/**
* @expectedException OutOfBoundsException
*/
public function testThrowsException()
{
$mock = m::mock('MyMockedClass');
$mock->shouldReceive('foo')->andThrow(new OutOfBoundsException);
$mock->foo();
#!/bin/sh
curl -s https://getcomposer.org/installer | php
php composer.phar create-project isidromerayo/simple_php_skeleton --dev
cd simple_php_skeleton
bin/phpunit
@isidromerayo
isidromerayo / gist:3691718
Created September 10, 2012 15:56
problems to create-project with Symfony2.x without version
$ composer.phar create-project symfony/framework-standard-edition demo_sf2.x
Installing symfony/framework-standard-edition (dev-master 506ffaab8d8474db2512fca879ca4b9877616a1e)
- Installing symfony/framework-standard-edition (dev-master master)
Cloning master
Created project in demo_sf2.x
Loading composer repositories with package information
Installing dependencies from lock file
Your lock file is out of sync with your composer.json, run "composer.phar update" to update dependencies
Your requirements could not be resolved to an installable set of packages.
@isidromerayo
isidromerayo / gist:3693366
Created September 10, 2012 19:48
ejemplos de .htaccess
http://www.catswhocode.com/blog/10-useful-htaccess-snippets-to-have-in-your-toolbox