|
@@ -1,12 +1,14 @@
|
|
|
<?php
|
|
<?php
|
|
|
|
|
|
|
|
-App::import('Model', 'Tools.Qlogin');
|
|
|
|
|
|
|
+App::uses('Qlogin', 'Tools.Model');
|
|
|
App::uses('MyCakeTestCase', 'Tools.Lib');
|
|
App::uses('MyCakeTestCase', 'Tools.Lib');
|
|
|
App::uses('Router', 'Routing');
|
|
App::uses('Router', 'Routing');
|
|
|
|
|
|
|
|
class QloginTest extends MyCakeTestCase {
|
|
class QloginTest extends MyCakeTestCase {
|
|
|
|
|
+
|
|
|
public $Qlogin = null;
|
|
public $Qlogin = null;
|
|
|
- //public $fixtures = array('app.code_key');
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public $fixtures = array('plugin.tools.code_key');
|
|
|
|
|
|
|
|
public function startTest() {
|
|
public function startTest() {
|
|
|
$this->Qlogin = ClassRegistry::init('Tools.Qlogin');
|
|
$this->Qlogin = ClassRegistry::init('Tools.Qlogin');
|
|
@@ -19,6 +21,8 @@ class QloginTest extends MyCakeTestCase {
|
|
|
public function testGenerate() {
|
|
public function testGenerate() {
|
|
|
$url = Router::url(array('admin'=>'', 'plugin'=>'tools', 'controller'=>'qlogin', 'action'=>'go'), true).'/';
|
|
$url = Router::url(array('admin'=>'', 'plugin'=>'tools', 'controller'=>'qlogin', 'action'=>'go'), true).'/';
|
|
|
pr($url);
|
|
pr($url);
|
|
|
|
|
+ $this->assertIsNotEmpty($url);
|
|
|
|
|
+
|
|
|
$res = $this->Qlogin->url(array('controller'=>'test', 'action'=>'foo', 'bar'), 1);
|
|
$res = $this->Qlogin->url(array('controller'=>'test', 'action'=>'foo', 'bar'), 1);
|
|
|
pr($res);
|
|
pr($res);
|
|
|
$this->assertTrue(is_string($res) && !empty($res));
|
|
$this->assertTrue(is_string($res) && !empty($res));
|
|
@@ -32,13 +36,14 @@ class QloginTest extends MyCakeTestCase {
|
|
|
public function testUse() {
|
|
public function testUse() {
|
|
|
$key = $this->Qlogin->generate(array('controller'=>'test', 'action'=>'foo', 'bar'), 1);
|
|
$key = $this->Qlogin->generate(array('controller'=>'test', 'action'=>'foo', 'bar'), 1);
|
|
|
$res = $this->Qlogin->translate($key);
|
|
$res = $this->Qlogin->translate($key);
|
|
|
- echo returns($res);
|
|
|
|
|
- pr($res);
|
|
|
|
|
|
|
+ $this->assertTrue(is_array($res) && !empty($res));
|
|
|
|
|
|
|
|
$key = $this->Qlogin->generate('/test/foo/bar', 2);
|
|
$key = $this->Qlogin->generate('/test/foo/bar', 2);
|
|
|
$res = $this->Qlogin->translate($key);
|
|
$res = $this->Qlogin->translate($key);
|
|
|
- echo returns($res);
|
|
|
|
|
- pr($res);
|
|
|
|
|
|
|
+ $this->assertTrue(is_array($res) && !empty($res));
|
|
|
|
|
+
|
|
|
|
|
+ $res = $this->Qlogin->translate('foobar');
|
|
|
|
|
+ $this->assertFalse($res);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//TODO
|
|
//TODO
|