Follow-up to test #12153: Added test cases for device condition
authorOliver Hader <oliver.hader@typo3.org>
Mon, 19 Oct 2009 20:43:02 +0000 (20:43 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 19 Oct 2009 20:43:02 +0000 (20:43 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@6171 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
tests/t3lib/t3lib_matchcondition_testcase.php

index d220878..470c343 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
        * Follow-up to test #12153: Fixed bug in language condition tests
        * Follow-up to test #12153: Refactored browserInfoHookIsCalled() test case
+       * Follow-up to test #12153: Added test cases for device condition
 
 2009-10-19  Rupert Germann  <rupi@gmx.li>
 
index e3b5eba..59b01da 100644 (file)
@@ -155,6 +155,44 @@ class t3lib_matchCondition_testcase extends tx_phpunit_testcase {
        }
 
        /**
+        * Tests whether a device type condition matches a crawler.
+        * @test
+        */
+       public function deviceConditionMatchesRobot() {
+               $_SERVER['HTTP_USER_AGENT'] = 'Googlebot/2.1 (+http://www.google.com/bot.html)';
+               $result = $this->matchCondition->match('[device = robot]');
+               $this->assertTrue($result);
+       }
+
+       /**
+        * Tests whether a device type condition does not match a crawler.
+        * @test
+        */
+       public function deviceConditionDoesNotMatchRobot() {
+               $_SERVER['HTTP_USER_AGENT'] = md5('Some strange user agent');
+               $result = $this->matchCondition->match('[device = robot]');
+               $this->assertFalse($result);
+       }
+
+       /**
+        * Tests whether the whichDevice hook is called.
+        *
+        * @return      void
+        * @test
+        */
+       public function whichDeviceHookIsCalled() {
+               $classRef = uniqid('tx_whichDeviceHook');
+               $whichDeviceHookMock = $this->getMock($classRef, array('whichDevice'));
+               $whichDeviceHookMock->expects($this->atLeastOnce())->method('whichDevice');
+
+               $GLOBALS['T3_VAR']['getUserObj'][$classRef] = $whichDeviceHookMock;
+               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'][$classRef] = $classRef;
+
+               $this->matchCondition->__construct();
+               $this->matchCondition->match('[device = robot]');
+       }
+
+       /**
         * Tests whether the language comparison matches.
         * @test
         */