QloginTest.php 1.4 KB

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