QloginTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. App::import('Model', 'Tools.Qlogin');
  3. App::uses('MyCakeTestCase', 'Tools.Lib');
  4. App::uses('Router', 'Routing');
  5. class QloginTest extends MyCakeTestCase {
  6. public $Qlogin = null;
  7. //public $fixtures = array('app.code_key');
  8. public function startTest() {
  9. $this->Qlogin = ClassRegistry::init('Tools.Qlogin');
  10. }
  11. public function testQloginInstance() {
  12. $this->assertTrue(is_a($this->Qlogin, 'Qlogin'));
  13. }
  14. public function testGenerate() {
  15. $url = Router::url(array('admin'=>'', 'plugin'=>'tools', 'controller'=>'qlogin', 'action'=>'go'), true).'/';
  16. pr($url);
  17. $res = $this->Qlogin->url(array('controller'=>'test', 'action'=>'foo', 'bar'), 1);
  18. pr($res);
  19. $this->assertTrue(is_string($res) && !empty($res));
  20. $this->assertTrue(strpos($res, $url) === 0);
  21. $res = $this->Qlogin->url('/test/foo/bar', 2);
  22. pr($res);
  23. $this->assertTrue(is_string($res) && !empty($res));
  24. }
  25. public function testUse() {
  26. $key = $this->Qlogin->generate(array('controller'=>'test', 'action'=>'foo', 'bar'), 1);
  27. $res = $this->Qlogin->translate($key);
  28. echo returns($res);
  29. pr($res);
  30. $key = $this->Qlogin->generate('/test/foo/bar', 2);
  31. $res = $this->Qlogin->translate($key);
  32. echo returns($res);
  33. pr($res);
  34. }
  35. //TODO
  36. }