CurrencyLibTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. */
  15. public function testConvert() {
  16. $this->out('<h2>30 EUR in USD</h2>', true);
  17. $is = $this->CurrencyLib->convert(30, 'EUR', 'USD');
  18. $this->debug($is);
  19. $this->assertTrue($is > 30 && $is < 60);
  20. $this->assertFalse($this->CurrencyLib->cacheFileUsed());
  21. }
  22. public function testIsAvailable() {
  23. $is = $this->CurrencyLib->isAvailable('EUR');
  24. $this->assertTrue($is);
  25. $is = $this->CurrencyLib->isAvailable('XYZ');
  26. $this->assertFalse($is);
  27. }
  28. public function testTable() {
  29. $this->out('<h2>Currency Table</h2>', true);
  30. $is = $this->CurrencyLib->table();
  31. $this->debug($is);
  32. $this->assertTrue(is_array($is) && !empty($is));
  33. $is = $this->CurrencyLib->table('XYZ');
  34. $this->assertFalse($is);
  35. $this->assertTrue($this->CurrencyLib->cacheFileUsed());
  36. }
  37. public function testReset() {
  38. $res = $this->CurrencyLib->reset();
  39. $this->assertTrue($res === null || $res === true);
  40. }
  41. }