Browse Source

Fix tests.

mscherer 6 years ago
parent
commit
1c800f5d4d

+ 7 - 16
tests/TestCase/BootstrapTest.php

@@ -5,9 +5,6 @@ namespace Tools\Test\TestCase;
 use DateTime;
 use Tools\TestSuite\TestCase;
 
-/**
- * RssViewTest
- */
 class BootstrapTest extends TestCase {
 
 	/**
@@ -19,8 +16,6 @@ class BootstrapTest extends TestCase {
 	}
 
 	/**
-	 * BootstrapTest::testStartsWith()
-	 *
 	 * @return void
 	 */
 	public function testStartsWith() {
@@ -57,8 +52,6 @@ class BootstrapTest extends TestCase {
 	}
 
 	/**
-	 * BootstrapTest::testEndsWith()
-	 *
 	 * @return void
 	 */
 	public function testEndsWith() {
@@ -95,8 +88,6 @@ class BootstrapTest extends TestCase {
 	}
 
 	/**
-	 * BootstrapTest::testContains()
-	 *
 	 * @return void
 	 */
 	public function testContains() {
@@ -136,26 +127,28 @@ class BootstrapTest extends TestCase {
 	 * @return void
 	 */
 	public function testEnt() {
-		//$this->assertEquals($expected, $is);
+		$is = ent('<b>');
+		$this->assertSame('&lt;b&gt;', $is);
 	}
 
 	/**
 	 * @return void
 	 */
 	public function testEntDec() {
-		//$this->assertEquals($expected, $is);
+		$is = entDec('&lt;b&gt;');
+		$this->assertSame('<b>', $is);
 	}
 
 	/**
 	 * @return void
 	 */
 	public function testReturns() {
-		//$this->assertEquals($expected, $is);
+		$foo = 1;
+		$is = returns($foo);
+		$this->assertSame('(int)1', $is);
 	}
 
 	/**
-	 * BootstrapTest::testExtractPathInfo()
-	 *
 	 * @return void
 	 */
 	public function testExtractPathInfo() {
@@ -173,8 +166,6 @@ class BootstrapTest extends TestCase {
 	}
 
 	/**
-	 * BootstrapTest::testExtractFileInfo()
-	 *
 	 * @return void
 	 */
 	public function testExtractFileInfo() {

+ 17 - 5
tests/TestCase/Controller/Component/MobileComponentTest.php

@@ -92,7 +92,7 @@ class MobileComponentTest extends TestCase {
 	 */
 	public function testMobileForceActivated() {
 		$request = $this->Controller->getRequest()
-			->withAttribute('params', ['controller' => 'MyController'])
+			->withAttribute('params', ['controller' => 'MyController', 'action' => 'myAction'])
 			->withQueryParams(['mobile' => 1]);
 		$this->Controller->setRequest($request);
 
@@ -105,7 +105,7 @@ class MobileComponentTest extends TestCase {
 
 		$configure = Configure::read('User');
 		$this->assertSame(['isMobile' => 0, 'setMobile' => 1], $configure);
-		$this->assertEquals(['desktopUrl' => '/my-controller?mobile=0'], $this->Controller->viewVars);
+		$this->assertEquals(['desktopUrl' => '/my-controller/my-action?mobile=0'], $this->Controller->viewVars);
 	}
 
 	/**
@@ -113,7 +113,7 @@ class MobileComponentTest extends TestCase {
 	 */
 	public function testMobileForceDeactivated() {
 		$request = $this->Controller->getRequest()
-			->withAttribute('params', ['controller' => 'MyController'])
+			->withAttribute('params', ['controller' => 'MyController', 'action' => 'myAction'])
 			->withQueryParams(['mobile' => 0]);
 		$this->Controller->setRequest($request);
 
@@ -124,7 +124,7 @@ class MobileComponentTest extends TestCase {
 		$this->Controller->Mobile->setMobile();
 		$configure = Configure::read('User');
 		$this->assertSame(['isMobile' => 0, 'setMobile' => 0], $configure);
-		$this->assertEquals(['mobileUrl' => '/my-controller?mobile=1'], $this->Controller->viewVars);
+		$this->assertEquals(['mobileUrl' => '/my-controller/my-action?mobile=1'], $this->Controller->viewVars);
 	}
 
 	/**
@@ -133,6 +133,10 @@ class MobileComponentTest extends TestCase {
 	public function testMobileFakeMobile() {
 		$_SERVER['HTTP_USER_AGENT'] = 'Some Android device';
 
+		$request = $this->Controller->getRequest()
+			->withAttribute('params', ['controller' => 'MyController', 'action' => 'myAction']);
+		$this->Controller->setRequest($request);
+
 		$this->Controller->Mobile->beforeFilter($this->event);
 		$this->assertTrue($this->Controller->Mobile->isMobile);
 
@@ -145,7 +149,11 @@ class MobileComponentTest extends TestCase {
 	 * @return void
 	 */
 	public function testMobileFakeMobileForceDeactivated() {
-		$this->Controller->setRequest($this->Controller->getRequest()->withQueryParams(['mobile' => 0]));
+		$request = $this->Controller->getRequest()
+			->withAttribute('params', ['controller' => 'MyController', 'action' => 'myAction'])
+			->withQueryParams(['mobile' => 0]);
+		$this->Controller->setRequest($request);
+
 		$_SERVER['HTTP_USER_AGENT'] = 'Some Android device';
 
 		$this->Controller->Mobile->beforeFilter($this->event);
@@ -168,6 +176,10 @@ class MobileComponentTest extends TestCase {
 		$this->Controller->Mobile->setConfig('auto', true);
 		$_SERVER['HTTP_USER_AGENT'] = 'Some Android device';
 
+		$request = $this->Controller->getRequest()
+			->withAttribute('params', ['controller' => 'MyController', 'action' => 'myAction']);
+		$this->Controller->setRequest($request);
+
 		$this->Controller->Mobile->beforeFilter($this->event);
 		$this->assertTrue($this->Controller->Mobile->isMobile);
 

+ 2 - 3
tests/TestCase/Utility/TextTest.php

@@ -55,11 +55,10 @@ TXT;
 	 */
 	public function testConvertToOrd() {
 		$is = $this->Text->convertToOrd('h H');
-		//pr($is);
 		$this->assertEquals($is, '0-104-32-72-0');
 
 		$is = $this->Text->convertToOrd('x' . PHP_EOL . 'x' . PHP_EOL . 'x' . PHP_EOL . 'x' . PHP_EOL . 'x' . "\t" . 'x');
-		//pr($is);
+		$this->assertNotEmpty($is);
 	}
 
 	/**
@@ -67,7 +66,7 @@ TXT;
 	 */
 	public function testConvertToOrdTable() {
 		$is = $this->Text->convertToOrdTable('x' . PHP_EOL . 'x' . PHP_EOL . 'x' . PHP_EOL . 'x' . PHP_EOL . 'x' . "\t" . 'x');
-		//pr($is);
+		$this->assertNotEmpty($is);
 	}
 
 	/**