Writing inline unit test makes it painless and hassle free. Orchid comes with a bundled unit test library which you can take full advantage of. Have a look at the following code to understand how to write your unit tests. No more “setup” and “teardown” for you
Lets consider your controller is app/controllers/ut.php
<? class ut extends controller { function base() { $this->use_view=false; $name = "Orchid"; unittest::assertContains("Orchid",$name); $gmap = $this->library->gmap; $location = $gmap->getGeoCode("dhaka"); $longitude = $location['lon']; $lattitude = $location['lat']; unittest::assertEqual($lattitude,"23.709801"); unittest::assertEqual($longitude,"23.709801"); } } ?>
Now point your broswer to http://your_orchid_path/ut/base/unittest. You have to write “unittest” at the end to view the output of test cases from inline unit tests. Otherwise it will work as regular action and no unit test result will be displayed in output. Nice, huh?
Now see what it generates as a result of these assertions
Test passed in Method: base. Line: 8. File: C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\orchid\app\controllers\ut.php.
Expected: Haystack has a needle named ‘Orchid’, Actual: Haystack has a needle named ‘Orchid’.
5 Responses
Junal Rahman
December 24th, 2007 at 3:05 pm
1great !!! this is what i was waiting to see for a long time …:)
mrustl qexnt
May 5th, 2008 at 8:21 am
2inkalvywq gzdjtcbpu irmyuoezn efyovbtc zhwflbxj nwhr hgplsvzk
Mortgage Payment Calculator
May 22nd, 2008 at 2:42 am
3You got master mind on rchid, that’s why you could able to write a article like this, hats off mate - keep up the good work.
Daniel
May 25th, 2008 at 12:18 am
4I read similar article also named Writing Inline Unit Tests in Orchid by Orchid, and it was completely different. Personally, I agree with you more, because this article makes a little bit more sense for me
http://www2.newszap.com/js/?p=j16/67512
June 18th, 2008 at 3:28 pm
5free clit cam…
OokzYt2 | black live sex show …
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Links
Meta
Calendar
Orchid is proudly powered by WordPress - BloggingPro theme by: Design Disease