public function tearDown() { parent::tearDown(); $this->Data->cleanUp(); ClassRegistry::flush(); Configure::write('Media', $this->oldConfig); }
public function testVerifyToken() { $rpcStub = $this->rpcStubBuilder->setMethods(array('getGitkitCerts'))->getMock(); $rpcStub->expects($this->once())->method('getGitkitCerts')->will($this->returnValue(TestData::getCerts())); $gitkitClient = Gitkit_Client::createFromConfig($this->config, $rpcStub); $user = $gitkitClient->validateToken(TestData::getToken()); $this->assertNotNull($user); }
public function __construct() { if (!isset($_SESSION[$GLOBALS['app_id']]['pk'])) { // start fake pks at 1020, after the hard-coded getData() events $_SESSION[$GLOBALS['app_id']]['pk'] = 1020; // populate $_SESSION with default data $_SESSION[$GLOBALS['app_id']]['rs'] = TestData::getEvents(); } }
static function getApiStatus($app) { $data = TestData::userTableTestVal(); if ($data) { return $app->render(200, array('test' => 'Database test query successful.')); } else { return $app->render(400, array('test' => 'Database test query failed.')); } }
public function sessionContestProvider() { $bad = array(null, '', 0, TestData::genASCIIStr(24), 'session_ok', 'contest_ok'); for ($i = 0; $i < sizeof($bad); $i++) { for ($k = 0; $k < sizeof($bad); $k++) { if ($bad[$i] != 'session_ok' || $bad[$k] != 'contest_ok') { $res[] = array($bad[$i], $bad[$k]); } } } return $res; }
public function loginPassProvider() { $res = array(); $bad_input = array(null, '', 42, TestData::genUnicodeStr(rand(0, 1) ? rand(1, TestData::MIN_LP_LENGTH) : rand(TestData::MAX_LP_LENGTH, 2 * TestData::MAX_LP_LENGTH))); $roles = array('SuperAdmin', 'ContestAdmin', 'Participant'); //bad data for all roles for ($i = 0; $i < sizeof($roles); $i++) { $res[] = array(BAD_DATA, TestData::getRandomValue($bad_input), TestData::getRandomValue($bad_input), $roles[$i]); } //bad data for super admin but good for everyone else $lp_len = rand(TestData::MIN_LP_LENGTH, TestData::MAX_LP_LENGTH); $res[] = array(BAD_DATA, TestData::genUnicodeStr($lp_len), TestData::genUnicodeStr($lp_len), 'SuperAdmin'); return $res; }
public function testGroupedHasMany() { $assoc = array('Photo' => array('className' => 'Media.Attachment', 'foreignKey' => 'foreign_key', 'conditions' => array('Photo.model' => 'Movie', 'Photo.group' => 'photo'), 'dependent' => true)); $Model = $this->_model('hasMany', $assoc); $fileA = $this->Data->getFile(array('image-png.png' => 'ta.png')); $fileB = $this->Data->getFile(array('image-png.png' => 'tb.png')); $data = array('Movie' => array('title' => 'Weekend', 'director' => 'Jean-Luc Godard'), 'Photo' => array(array('file' => $fileA, 'model' => 'Movie', 'group' => 'photo'), array('file' => $fileB, 'model' => 'Movie', 'group' => 'photo'))); $Model->create(); $result = $Model->saveAll($data, array('validate' => 'first')); $this->assertTrue($result); $this->assertTrue(file_exists($this->Data->settings['transfer'] . 'img' . DS . 'ta.png')); $this->assertTrue(file_exists($this->Data->settings['transfer'] . 'img' . DS . 'tb.png')); $result = $Model->find('first', array('conditions' => array('title' => 'Weekend'))); $expected = array('Movie' => array('id' => '4', 'title' => 'Weekend', 'director' => 'Jean-Luc Godard'), 'Actor' => array(), 'Photo' => array(0 => array('id' => '1', 'model' => 'Movie', 'foreign_key' => '4', 'dirname' => 'img', 'basename' => 'ta.png', 'checksum' => '0ec724ac451b85f09e4652d29eff943e', 'group' => 'photo', 'alternative' => null, 'path' => 'img/ta.png'), 1 => array('id' => '2', 'model' => 'Movie', 'foreign_key' => '4', 'dirname' => 'img', 'basename' => 'tb.png', 'checksum' => '0ec724ac451b85f09e4652d29eff943e', 'group' => 'photo', 'alternative' => null, 'path' => 'img/tb.png'))); $this->assertEqual($result, $expected); $result = $Model->delete($Model->getLastInsertID()); $this->assertTrue($result); $this->assertFalse(file_exists($this->Data->settings['transfer'] . 'photo' . DS . 'ta.png')); $this->assertFalse(file_exists($this->Data->settings['transfer'] . 'photo' . DS . 'tb.png')); }
public function testFolder() { $file = dirname(__FILE__); $result = MediaValidation::folder($file); $this->assertTrue($result); $file = $this->Data->getFile('image-jpg.jpg'); $result = MediaValidation::folder($file, false); $this->assertTrue($result); $file = $this->Data->settings['base'] . 'i-am-not-a-file.png'; $result = MediaValidation::folder($file); $this->assertFalse($result); $file = TMP; $result = MediaValidation::folder($file); $this->assertTrue($result); $file = TMP; $result = MediaValidation::folder($file, false); $this->assertTrue($result); $file = TMP . DS . DS . DS; $result = MediaValidation::folder($file, false); $this->assertTrue($result); }
public function badFilenameProvider() { return TestData::getData('createPluginFilename'); }
protected function apiGetUsers() { $req = TestData::fillRequest('GetUsersRequest'); $req->sessionID = $this->sessionID; $req->contestID = $this->contestID; $res = RequestSender::send($req); $this->assertClassEquals(new GetUsersResponse(), $res); return $res->users; }
/** * Run test method */ public function run() { try { $method = $this->_validateMethodName(); /** * Example * * $this->_api->product()->apiList() * $this->_api->order()->apiAdd() */ $result = call_user_func(array(call_user_func(array($this->_api, $method['section'])), $method['method']), TestData::data($method)); //View result var_dump($result); } catch (Exception $e) { echo "#" . $e->getCode() . " " . $e->getMessage() . "\n"; } }
public static function genUserDescription($dataFieldsQnt) { if ($dataFieldsQnt < 0) { throw new InvalidArgumentException(); } $ud = new UserDescription(); $ud->login = TestData::genUnicodeStr(TestData::ALLOWED_UNICODE_LP_LENGTH); $ud->password = TestData::genUnicodeStr(TestData::ALLOWED_UNICODE_LP_LENGTH); $ud->userType = TestData::getRandomValue(array('Participant', 'ContestAdmin')); for ($i = 0; $i < $dataFieldsQnt; $i++) { $ud->dataValue[] = TestData::genUnicodeStr(TestData::MAX_DATA_LENGTH); } return $ud; }
public function badLoginPassProvider() { return TestData::getData('badLoginPass'); }
public function disconnectionDataProvider() { return TestData::getData('disconnectContest'); }
public function userDataProvider() { $res = TestData::getData('regToContest'); //TODO: add bad data generator for super-long passwords and logins return $res; }
public function generalParametersDataProvider() { $res = array(); $input = array(null, 42, ''); for ($i = 0; $i < 3; $i++) { for ($j = 0; $j < 3; $j++) { $res[] = array(BAD_DATA, $input[$i], $input[$j]); } } $res[] = array(GOOD_DATA, TestData::genUnicodeStr(rand(1, TestData::MAX_DATA_LENGTH)), TestData::genUnicodeStr(rand(1, TestData::MAX_DATA_LENGTH))); return $res; }
public function testEmbedAsObject() { $result = $this->Media->embedAsObject('http://example.com/img/image-png'); $this->assertFalse($result); $result = $this->Media->embedAsObject('img/image-png', array('url' => 'http://example.com')); $expected = '<a href="http://example.com"><img src="/media/static/img/image-png.png" height="54" width="70"/></a>'; $this->assertEqual($result, $expected); $result = $this->Media->embedAsObject('img/image-png', array('checked' => true, 'disabled' => true, 'noresize' => true, 'required' => true)); $expected = '<object type="image/png" data="/media/static/img/image-png.png" checked="checked" disabled="disabled" noresize="noresize" required="required"><param name="src" value="/media/static/img/image-png.png"/></object>'; $this->assertEqual($result, $expected); $result = $this->Media->embedAsObject('img/special-image-&-png'); $expected = '<object type="image/png" data="http://fo&o:bar@example.com/media/special%5Bfolder%5D/img/special-image-%26-png.png"><param name="src" value="http://fo&o:bar@example.com/media/special%5Bfolder%5D/img/special-image-%26-png.png"/></object>'; $this->assertEqual($result, $expected); $result = $this->Media->embedAsObject('img/image-png', array('id' => 'my-image', 'class' => 'image', 'data-custom' => 42)); $expected = '<object type="image/png" data="/media/static/img/image-png.png" id="my-image" class="image" data-custom="42"><param name="src" value="/media/static/img/image-png.png"/></object>'; $this->assertEqual($result, $expected); $this->Data->getFile(array('video-wmv.wmv' => $this->Data->settings['static'] . 'vid/video-wmv.wmv')); $result = $this->Media->embedAsObject('vid/video-wmv'); $expected = '<object type="video/x-ms-wmv" data="/media/static/vid/video-wmv.wmv" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"><param name="src" value="/media/static/vid/video-wmv.wmv"/> <param name="controller" value="true"/> <param name="pluginspage" value="http://www.microsoft.com/Windows/MediaPlayer/"/></object>'; $this->assertEqual($result, $expected); $this->Data->getFile(array('video-rm.rm' => $this->Data->settings['static'] . 'vid/video-rm.rm')); $result = $this->Media->embedAsObject('vid/video-rm'); $expected = '<object type="application/vnd.rn-realmedia" data="/media/static/vid/video-rm.rm" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"><param name="src" value="/media/static/vid/video-rm.rm"/> <param name="controls" value="ControlPanel"/> <param name="console" value="video5268463f37ca4"/> <param name="nologo" value="true"/> <param name="nojava" value="true"/> <param name="center" value="true"/> <param name="pluginspage" value="http://www.real.com/player/"/></object>'; $pattern = str_replace('video5268463f37ca4', 'video.{13}', preg_quote($expected, '/')); $this->assertRegExp('/^' . $pattern . '$/', $result); $this->Data->getFile(array('video-mov.mov' => $this->Data->settings['static'] . 'vid/video-mov.mov')); $result = $this->Media->embedAsObject('vid/video-mov'); $expected = '<object type="video/quicktime" data="/media/static/vid/video-mov.mov" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="/media/static/vid/video-mov.mov"/> <param name="controller" value="true"/> <param name="pluginspage" value="http://www.apple.com/quicktime/download/"/></object>'; $this->assertEqual($result, $expected); $this->Data->getFile(array('video-mpg.mpg' => $this->Data->settings['static'] . 'vid/video-mpg.mpg')); $result = $this->Media->embedAsObject('vid/video-mpg'); $expected = '<object type="video/mpeg" data="/media/static/vid/video-mpg.mpg"><param name="src" value="/media/static/vid/video-mpg.mpg"/></object>'; $this->assertEqual($result, $expected); $this->Data->getFile(array('video-swf.swf' => $this->Data->settings['static'] . 'vid/video-swf.swf')); $result = $this->Media->embedAsObject('vid/video-swf'); $expected = '<object type="application/x-shockwave-flash" data="/media/static/vid/video-swf.swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"><param name="movie" value="/media/static/vid/video-swf.swf"/> <param name="wmode" value="transparent"/> <param name="FlashVars" value="playerMode=embedded"/> <param name="quality" value="best"/> <param name="scale" value="noScale"/> <param name="salign" value="TL"/> <param name="pluginspage" value="http://www.adobe.com/go/getflashplayer"/></object>'; $this->assertEqual($result, $expected); $this->Data->getFile(array('application-pdf.pdf' => $this->Data->settings['static'] . 'doc/application-pdf.pdf')); $result = $this->Media->embedAsObject('doc/application-pdf'); $expected = '<object type="application/pdf" data="/media/static/doc/application-pdf.pdf"><param name="src" value="/media/static/doc/application-pdf.pdf"/> <param name="toolbar" value="true"/> <param name="scrollbar" value="true"/> <param name="navpanes" value="true"/></object>'; $this->assertEqual($result, $expected); $this->Data->getFile(array('audio-mp3.mp3' => $this->Data->settings['static'] . 'aud/audio-mp3.mp3')); $result = $this->Media->embedAsObject('aud/audio-mp3'); $expected = '<object type="audio/mpeg" data="/media/static/aud/audio-mp3.mp3"><param name="src" value="/media/static/aud/audio-mp3.mp3"/></object>'; $this->assertEqual($result, $expected); $result = $this->Media->embedAsObject('img/image-png'); $expected = '<object type="image/png" data="/media/static/img/image-png.png"><param name="src" value="/media/static/img/image-png.png"/></object>'; $this->assertEqual($result, $expected); $result = $this->Media->embedAsObject('non-existent'); $expected = ''; $this->assertEqual($result, $expected); }