muscle memory so when the ball comes you will know how to act TDD is more of a mindset Software development is a 'Product' not 'Project', it has a long life cycle A good dev is able to pass the code to readble code to the new guy, not the ability to hack legacy !!
range exercise again with TDD class RangeSpec extends PHPUnit_Framework_TestCase{ function testCloseRangeFromZeroToFive(){ $this->assertEquals("{0,1,2,3,4,5}",rangeZeroToFive("[0,5]");) } } ... function rangeZeroToFive($range){ $openSignPosition = 0; $closeSignPosition = 4; if ($range[openSignPosition]=="("){ return ({0,1,2,3,4,5}); } else if ($range[closeSignPosition]==")") { .... } }
because it is required but it is not really matter what those vaules is » Stub - "Fake" clock example » Mock - Similar to stub but also care about Behaviour "Execute database connention only one time » Spy - Usually use with Legacy code. Send spy "object" into private or hard to read method to try to understand it work
function testStub() { // Create a stub for the SomeClass class. $stub = $this->getMock('SomeClass'); // Configure the stub. $stub->expects($this->any()) ->method('doSomething') ->will($this->returnValue('foo')); // Calling $stub->doSomething() will now return // 'foo'. $this->assertEquals('foo', $stub->doSomething()); } } ?>
to Silex 2 composer update 3 create index.php to test if the Silex is up 4 run php -S locahost:8888 5 go to URL http://localhost:8888/hello/Pondd 6 now try to get it to call CaptCha 7 try to split View and Controller