Alpha Framework alpha--tests
[ class tree: alpha--tests ] [ index: alpha--tests ] [ all elements ]

Source for file AlphaAgentUtils_Test.php

Documentation is available at AlphaAgentUtils_Test.php

  1. <?php
  2.  
  3. require_once $config->get('sysRoot').'alpha/util/AlphaAgentUtils.inc';
  4.  
  5. /**
  6.  *
  7.  * Test cases for the AlphaAgentUtils class
  8.  * 
  9.  * @package alpha::tests
  10.  * @since 1.0
  11.  * @author John Collins <dev@alphaframework.org>
  12.  * @version $Id: AlphaAgentUtils_Test.php 1453 2011-12-04 15:12:54Z johnc $
  13.  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
  14.  * @copyright Copyright (c) 2011, John Collins (founder of Alpha Framework).
  15.  *  All rights reserved.
  16.  * 
  17.  *  <pre>
  18.  *  Redistribution and use in source and binary forms, with or
  19.  *  without modification, are permitted provided that the
  20.  *  following conditions are met:
  21.  * 
  22.  *  * Redistributions of source code must retain the above
  23.  *    copyright notice, this list of conditions and the
  24.  *    following disclaimer.
  25.  *  * Redistributions in binary form must reproduce the above
  26.  *    copyright notice, this list of conditions and the
  27.  *    following disclaimer in the documentation and/or other
  28.  *    materials provided with the distribution.
  29.  *  * Neither the name of the Alpha Framework nor the names
  30.  *    of its contributors may be used to endorse or promote
  31.  *    products derived from this software without specific
  32.  *    prior written permission.
  33.  *   
  34.  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  35.  *  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  36.  *  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  37.  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  39.  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  41.  *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  42.  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  43.  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  44.  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  45.  *  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  46.  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  47.  *  </pre>
  48.  *  
  49.  */
  50. class AlphaAgentUtils_Test extends PHPUnit_Framework_TestCase {
  51.     /**
  52.      * Called before the test functions will be executed
  53.      * this function is defined in PHPUnit_TestCase and overwritten
  54.      * here
  55.      * 
  56.      * @since 1.0
  57.      */
  58.     protected function setUp({
  59.     }
  60.     
  61.     /** 
  62.      * Called after the test functions are executed
  63.      * this function is defined in PHPUnit_TestCase and overwritten
  64.      * here
  65.      * 
  66.      * @since 1.0
  67.      */    
  68.     protected function tearDown({
  69.     }
  70.     
  71.     /**
  72.      * Testing various browser agent strings to ensure that they are not mistakenly threated as bots
  73.      */
  74.     public function testIsBotFalse({
  75.         $this->assertFalse(AlphaAgentUtils::isBot('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)')'testing that IE 6 is not a bot');
  76.         $this->assertFalse(AlphaAgentUtils::isBot('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6')'testing that FF 3.6 is not a bot');
  77.     }
  78.     
  79.     /**
  80.      * Testing various spider bot agent strings to ensure that they are correctly threated as bots
  81.      */
  82.     public function testIsBotTrue({
  83.         $this->assertTrue(AlphaAgentUtils::isBot('Googlebot/2.1 (+http://www.googlebot.com/bot.html)')'testing that Google is a bot');
  84.         $this->assertTrue(AlphaAgentUtils::isBot('Gigabot/1.0')'testing that Gigabot is a bot');
  85.     }
  86. }
  87.  
  88. ?>

Documentation generated on Tue, 13 Dec 2011 20:25:30 +0000 by phpDocumentor 1.4.3