public function testCreate() { new CM_Splittest_Fixture(new CM_Http_Request_Post('/foo/null')); new CM_Splittest_Fixture(CMTest_TH::createUser()); try { new CM_Splittest_Fixture(CMTest_TH::createSession()); $this->fail('Should not be able to create a fixture from a session'); } catch (CM_Exception_Invalid $e) { $this->assertContains('Invalid fixture type', $e->getMessage()); } }
private function _generateWowzaData(array $streamChannels) { $jsonData = array(); /** @var CM_Model_StreamChannel_Video $streamChannel */ foreach ($streamChannels as $streamChannel) { $subscribes = array(); /** @var CM_Model_Stream_Publish $streamPublish */ $streamPublish = $streamChannel->getStreamPublish(); /** @var CM_Model_Stream_Subscribe $streamSubscribe */ foreach ($streamChannel->getStreamSubscribes() as $streamSubscribe) { $session = CMTest_TH::createSession($streamSubscribe->getUser()); $subscribes[$streamSubscribe->getKey()] = array('startTimeStamp' => $streamSubscribe->getStart(), 'clientId' => $streamSubscribe->getKey(), 'data' => json_encode(array('sessionId' => $session->getId()))); } $session = CMTest_TH::createSession($streamPublish->getUser()); $jsonData[$streamChannel->getKey()] = array('startTimeStamp' => $streamPublish->getStart(), 'clientId' => $streamPublish->getKey(), 'data' => json_encode(array('sessionId' => $session->getId(), 'streamChannelType' => $streamChannel->getType())), 'subscribers' => $subscribes, 'thumbnailCount' => 2, 'width' => 480, 'height' => 720, 'wowzaIp' => ip2long('192.168.0.1')); } return json_encode($jsonData); }
public function testGetSession() { $session1 = CMTest_TH::createSession(); $sessionId1 = $session1->getId(); $session2 = CMTest_TH::createSession(); $sessionId2 = $session2->getId(); $params = new CM_Params(['foo' => $sessionId1, 'bar' => 'baz', 'baz' => $session2, 'quux' => 5]); $session1 = $params->getSession('foo'); $this->assertInstanceOf('CM_Session', $session1); $this->assertSame($sessionId1, $session1->getId()); $exception = $this->catchException(function () use($params) { $params->getSession('bar'); }); $this->assertInstanceOf('CM_Exception_InvalidParam', $exception); $this->assertSame('Session is not found', $exception->getMessage()); $session2 = $params->getSession('baz'); $this->assertInstanceOf('CM_Session', $session2); $this->assertSame($sessionId2, $session2->getId()); $exception = $this->catchException(function () use($params) { $params->getSession('quux'); }); $this->assertInstanceOf('CM_Exception_InvalidParam', $exception); $this->assertSame('Invalid param type for session', $exception->getMessage()); }