Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 11th, 2012  |  syntax: None  |  size: 1.04 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3.     /**
  4.      * The method that is being tested
  5.      */
  6.     public function generateKeyNumber($key) {
  7.         // If there are no spaces, reject
  8.         if (0 === substr_count($key, ' ')) {
  9.             return '';
  10.         }
  11.  
  12.         $int = (int)preg_replace('[\D]', '', $key) / substr_count($key, ' ');
  13.  
  14.         return (is_int($int)) ? $int : '';
  15.     }
  16.  
  17. /*****/
  18.  
  19.     /**
  20.      * The unit test
  21.      * @dataProvider KeyProvider
  22.      */
  23.     public function testKeySigningForHandshake($accept, $key) {
  24.         $this->assertEquals($accept, $this->_version->generateKeyNumber($key));
  25.     }
  26.  
  27.     public static function KeyProvider() {
  28.         return array(
  29.             array(179922739, '17  9 G`ZD9   2 2b 7X 3 /r90')
  30.           , array('', '17  9 G`ZD9   2 2b 7X 3 /r91')
  31.  
  32.             // This test fails on Travis CI, with exact same environment as two other tested, passing envs
  33.           , array(906585445, '3e6b263  4 17 80')
  34.  
  35.           , array('', '3e6b263 4 17 80')
  36.           , array('', '3e6b63 4 17 80')
  37.           , array('', '3e6b6341780')
  38.         );
  39.     }