Пример #1
0
 public function testGetServerId()
 {
     $adapter = new CM_Stream_Adapter_Video_Wowza();
     $ipAddresses = array('10.0.3.109', '10.0.3.108');
     foreach ($ipAddresses as $ipAddress) {
         $request = $this->getMockForAbstractClass('CM_Http_Request_Abstract', array($ipAddress), 'CM_Http_Request_Mock', true, true, true, array('getIp', 'getHost'));
         $request->expects($this->any())->method('getIp')->will($this->returnValue(sprintf('%u', ip2long($ipAddress))));
         $this->assertEquals(1, $adapter->getServerId($request));
     }
     try {
         $ipAddress = '66.66.66.66';
         $request = $this->getMockForAbstractClass('CM_Http_Request_Abstract', array($ipAddress), 'CM_Http_Request_Mock', true, true, true, array('getIp', 'getHost'));
         $request->expects($this->any())->method('getIp')->will($this->returnValue(sprintf('%u', ip2long($ipAddress))));
         $adapter->getServerId($request);
         $this->fail('Found server with incorrect ipAddress');
     } catch (CM_Exception_Invalid $e) {
         $this->assertContains('No video server', $e->getMessage());
         $this->assertContains('`66.66.66.66`', $e->getMessage());
     }
 }
Пример #2
0
 /**
  * @param int|null $type
  * @param int|null $adapterType
  * @return CM_Model_StreamChannel_Abstract
  */
 public static function createStreamChannel($type = null, $adapterType = null)
 {
     if (null === $type) {
         $type = CM_Model_StreamChannel_Video::getTypeStatic();
     }
     if (null === $adapterType) {
         $adapterType = CM_Stream_Adapter_Video_Wowza::getTypeStatic();
     }
     $data = array('key' => rand(1, 10000) . '_' . rand(1, 100));
     if (CM_Model_StreamChannel_Video::getTypeStatic() == $type) {
         $data['width'] = 480;
         $data['height'] = 720;
         $data['serverId'] = 1;
         $data['thumbnailCount'] = 0;
         $data['adapterType'] = $adapterType;
     }
     return CM_Model_StreamChannel_Abstract::createType($type, $data);
 }