CurrencyLibTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. App::uses('CurrencyLib', 'Tools.Lib');
  3. App::uses('MyCakeTestCase', 'Tools.TestSuite');
  4. class CurrencyLibTest extends MyCakeTestCase {
  5. public function setUp() {
  6. parent::setUp();
  7. $this->CurrencyLib = new CurrencyLib();
  8. }
  9. public function testStartReset() {
  10. $this->CurrencyLib->reset();
  11. }
  12. /**
  13. * test
  14. * 2010-06-05 ms
  15. */
  16. public function testConvert() {
  17. $this->out('<h2>30 EUR in USD</h2>', true);
  18. $is = $this->CurrencyLib->convert(30, 'EUR', 'USD');
  19. $this->debug($is);
  20. $this->assertTrue($is > 30 && $is < 60);
  21. $this->assertFalse($this->CurrencyLib->cacheFileUsed());
  22. }
  23. public function testIsAvailable() {
  24. $is = $this->CurrencyLib->isAvailable('EUR');
  25. $this->assertTrue($is);
  26. $is = $this->CurrencyLib->isAvailable('XYZ');
  27. $this->assertFalse($is);
  28. }
  29. public function testTable() {
  30. $this->out('<h2>Currency Table</h2>', true);
  31. $is = $this->CurrencyLib->table();
  32. $this->debug($is);
  33. $this->assertTrue(is_array($is) && !empty($is));
  34. $is = $this->CurrencyLib->table('XYZ');
  35. $this->assertFalse($is);
  36. $this->assertTrue($this->CurrencyLib->cacheFileUsed());
  37. }
  38. public function testReset() {
  39. $res = $this->CurrencyLib->reset();
  40. $this->assertTrue($res === null || $res === true);
  41. }
  42. }