Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Jun 16, 2014
1 parent d841910 commit 983967c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 37 deletions.
36 changes: 18 additions & 18 deletions core/tests/databaseDataset/default.xml
@@ -1,45 +1,45 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>

<folder folder_id="1" name="name Folder 1" description="Description Folder 1" left_indice="1" right_indice="2" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72800'
<folder folder_id="1" name="name Folder 1" description="Description Folder 1" privacy_status="0" left_indice="1" right_indice="2" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72800'
parent_id="-1"/>
<folderpolicygroup folder_id="1" group_id="0" policy='0' />
<folder folder_id="2" name="name Folder 2" description="Description Folder 2" left_indice="3" right_indice="4" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72801'
<folder folder_id="2" name="name Folder 2" description="Description Folder 2" privacy_status="0" left_indice="3" right_indice="4" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72801'
parent_id="-1"/>
<folder folder_id="3" name="name Folder 3" description="Description Folder 3" left_indice="5" right_indice="6" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72802'
<folder folder_id="3" name="name Folder 3" description="Description Folder 3" privacy_status="0" left_indice="5" right_indice="6" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72802'
parent_id="-1"/>

<community community_id="2000" name="Community test User 1"
description="Community test User 1" creation="2011-01-27 12:09:02" privacy="0" folder_id="1003"
admingroup_id="3000" moderatorgroup_id="3001" membergroup_id="3002"
uuid='4e311fdf82107d245f0798d654fc24205f2621eb72777' />

<folder folder_id="1000" name="User 1 name Folder 1" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72760'
<folder folder_id="1000" name="User 1 name Folder 1" privacy_status="2" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72760'
description="Description Folder 1" left_indice="1000" right_indice="1005"
parent_id="-1" />
<folderpolicyuser folder_id="1000" user_id="1" policy='2' />
<folder folder_id="1001" name="User 1 name Folder 2" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72761'
<folder folder_id="1001" name="User 1 name Folder 2" privacy_status="0" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72761'
description="Description Folder 2" left_indice="1001" right_indice="1002"
parent_id="1000" />
<folderpolicyuser folder_id="1001" user_id="1" policy='2' />
<folder folder_id="1002" name="User 1 name Folder 3" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72762'
<folder folder_id="1002" name="User 1 name Folder 3" privacy_status="2" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72762'
description="Description Folder 3" left_indice="1003" right_indice="1004"
parent_id="1000" />
<folderpolicyuser folder_id="1002" user_id="1" policy='2' />
<folder folder_id="1003" name="community_2000" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72763'
<folder folder_id="1003" name="community_2000" privacy_status="0" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72763'
description="Description Folder 1" left_indice="1006" right_indice="10011"
parent_id="-2" />
<folder folder_id="1004" name="Community test User 1 name Folder 2" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72764'
<folder folder_id="1004" name="Community test User 1 name Folder 2" privacy_status="0" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72764'
description="Description Folder 2" left_indice="1007" right_indice="1008"
parent_id="1003" />
<folder folder_id="1005" name="Community test User 1 name Folder 3" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72765'
<folder folder_id="1005" name="Community test User 1 name Folder 3" privacy_status="0" uuid='4e311fdf82007c245b07d8d6c4fcb4205f2621eb72765'
description="Description Folder 3" left_indice="1009" right_indice="1010"
parent_id="1003" />

<!-- Admin's folders -->
<folder folder_id="1006" name="user_3" description="" parent_id="-1" left_indice="1" right_indice="2" uuid="123890231890" />
<folder folder_id="1007" name="Public" description="" parent_id="1006" left_indice="2" right_indice="3" uuid="123890231891" />
<folder folder_id="1008" name="Private" description="" parent_id="1006" left_indice="3" right_indice="4" uuid="123890231892" />
<folder folder_id="1006" name="user_3" description="" privacy_status="2" parent_id="-1" left_indice="1" right_indice="2" uuid="123890231890" />
<folder folder_id="1007" name="Public" description="" privacy_status="0" parent_id="1006" left_indice="2" right_indice="3" uuid="123890231891" />
<folder folder_id="1008" name="Private" description="" privacy_status="2" parent_id="1006" left_indice="3" right_indice="4" uuid="123890231892" />

<group group_id="3000" community_id="2000" name="Community test User 1 Admin" />
<group group_id="3001" community_id="2000"
Expand Down Expand Up @@ -138,18 +138,18 @@
<group group_id="3003" community_id="2001" name="Community For Deletion Admin" />
<group group_id="3004" community_id="2001" name="Community For Deletion Moderator" />
<group group_id="3005" community_id="2001" name="Community For Deletion Member" />
<folder folder_id="1009" name="Community For Deletion Folder" description="" parent_id="-1" left_indice="1" right_indice="2" uuid="123890231890" />
<folder folder_id="1010" name="Community For Deletion Folder Public" description="" parent_id="1009" left_indice="2" right_indice="3" uuid="123890231891" />
<folder folder_id="1011" name="Community For Deletion Folder Private" description="" parent_id="1009" left_indice="3" right_indice="4" uuid="123890231892" />
<folder folder_id="1009" name="Community For Deletion Folder" description="" privacy_status="0" parent_id="-1" left_indice="1" right_indice="2" uuid="123890231890" />
<folder folder_id="1010" name="Community For Deletion Folder Public" description="" privacy_status="0" parent_id="1009" left_indice="2" right_indice="3" uuid="123890231891" />
<folder folder_id="1011" name="Community For Deletion Folder Private" description="" privacy_status="2" parent_id="1009" left_indice="3" right_indice="4" uuid="123890231892" />
<folderpolicygroup folder_id="1009" group_id="3003" policy='2' />
<folderpolicygroup folder_id="1009" group_id="3004" policy='1' />
<folderpolicygroup folder_id="1009" group_id="3005" policy='0' />

<folder folder_id="1012" name="Folder User 1 Read" description="" parent_id="1009" left_indice="3" right_indice="4" uuid="1012123890231892" />
<folder folder_id="1012" name="Folder User 1 Read" description="" privacy_status="0" parent_id="1009" left_indice="3" right_indice="4" uuid="1012123890231892" />
<folderpolicyuser folder_id="1012" user_id="1" policy='0' />
<folder folder_id="1013" name="Folder User 1 Write" description="" parent_id="1009" left_indice="3" right_indice="4" uuid="1013123890231892" />
<folder folder_id="1013" name="Folder User 1 Write" description="" privacy_status="0" parent_id="1009" left_indice="3" right_indice="4" uuid="1013123890231892" />
<folderpolicyuser folder_id="1013" user_id="1" policy='1' />
<folder folder_id="1014" name="Folder User 1 Admin" description="" parent_id="1009" left_indice="3" right_indice="4" uuid="1014123890231892" />
<folder folder_id="1014" name="Folder User 1 Admin" description="" privacy_status="0" parent_id="1009" left_indice="3" right_indice="4" uuid="1014123890231892" />
<folderpolicyuser folder_id="1014" user_id="1" policy='2' />
<folderpolicygroup folder_id="1014" group_id="3003" policy='2' />
<folderpolicygroup folder_id="1014" group_id="3004" policy='1' />
Expand Down
3 changes: 0 additions & 3 deletions modules/api/controllers/components/ApiComponent.php
Expand Up @@ -317,9 +317,6 @@ function linkCreate($args)
is supplied.
* @param filename The filename of the file you will upload, will be used as the
bitstream's name and the item's name (unless <b>itemname</b> is supplied).
* @param itemprivacy (Optional)
When passing the <b>folderid</b> param, the privacy status of the newly
created item, Default 'Public', possible values [Public|Private].
* @param itemdescription (Optional)
When passing the <b>folderid</b> param, the description of the item,
if not supplied the item's description will be blank.
Expand Down
13 changes: 5 additions & 8 deletions modules/api/tests/controllers/ApiCallItemMethodsTest.php
Expand Up @@ -588,7 +588,7 @@ public function testBitstreamUpload()
$this->_assertStatusFail($resp, MIDAS_INVALID_PARAMETER);

// 15
// test upload.generatetoken passing in folderid, default of Public
// test upload.generatetoken passing in folderid
$this->resetAll();
$this->params['token'] = $this->_loginAsNormalUser();
$this->params['method'] = 'midas.upload.generatetoken';
Expand All @@ -612,13 +612,12 @@ public function testBitstreamUpload()
// test that the properties of the item are as expected with defaults
$this->assertEquals($itemDao->getName(), $filename, 'Expected a different name for generated item');
$this->assertEquals($itemDao->getDescription(), '', 'Expected a different description for generated item');
$this->assertEquals($itemDao->getPrivacyStatus(), MIDAS_PRIVACY_PUBLIC, 'Expected a different privacy_status for generated item');
$this->assertEquals($itemDao->getPrivacyStatus(), MIDAS_PRIVACY_PRIVATE, 'Expected a different privacy_status for generated item');
// delete the newly created item
$this->Item->delete($itemDao);

// 16
// test upload.generatetoken passing in folderid and setting optional values,
// with Private itemprivacy
// test upload.generatetoken passing in folderid and setting optional values
$filename = 'test.txt';
$description = 'generated item description';
$itemname = 'generated item name';
Expand All @@ -627,7 +626,7 @@ public function testBitstreamUpload()
$this->params['method'] = 'midas.upload.generatetoken';
$this->params['filename'] = $filename;
$this->params['folderid'] = '1000';
$this->params['itemprivacy'] = 'Private';
$this->params['itemprivacy'] = 'Public';
$this->params['itemdescription'] = $description;
$this->params['itemname'] = $itemname;
$resp = $this->_callJsonApi();
Expand Down Expand Up @@ -790,7 +789,6 @@ public function testBitstreamUpload()
$this->params['filename'] = $filename;
$this->params['checksum'] = $md5;
$this->params['folderid'] = '1000';
$this->params['itemprivacy'] = 'Public';
$resp = $this->_callJsonApi();
$this->_assertStatusOk($resp);
$token = $resp->data->token;
Expand All @@ -801,8 +799,7 @@ public function testBitstreamUpload()
// this at least allows us to test it
$generatedItemId = $generatedItemId + 1;
$itemDao = $this->Item->load($generatedItemId);
// ensure privacy status when passing Public explicitly
$this->assertEquals($itemDao->getPrivacyStatus(), MIDAS_PRIVACY_PUBLIC, 'Expected a different privacy_status for generated item');
$this->assertEquals($itemDao->getPrivacyStatus(), MIDAS_PRIVACY_PRIVATE, 'Expected a different privacy_status for generated item');
$revisions = $itemDao->getRevisions();
$this->assertEquals(count($revisions), 1, 'Wrong number of revisions in the item');
$bitstreams = $revisions[0]->getBitstreams();
Expand Down
2 changes: 1 addition & 1 deletion tests/DatabaseSetup.php
Expand Up @@ -105,7 +105,7 @@ function installCore($db, $dbType, $utilityComponent)

$newestVersion = $upgradeComponent->getNewestVersion(true);

$sqlFile = BASE_PATH.'/core/database/{$dbType}/'.$newestVersion.'.sql';
$sqlFile = BASE_PATH.'/core/database/'.$dbType.'/'.$newestVersion.'.sql';
if(!isset($sqlFile) || !file_exists($sqlFile))
{
throw new Zend_Exception('Unable to find sql file: '.$sqlFile);
Expand Down
8 changes: 4 additions & 4 deletions tests/Utf8tools.php
Expand Up @@ -18,12 +18,12 @@
limitations under the License.
=========================================================================*/

/** tools for detecting non utf8 files and tranforming non utf8 files to utf8. */
/** tools for detecting non utf8 files and transforming non utf8 files to utf8. */
class Utf8tools
{
protected $excludedDirs = array('data', 'library', 'tmp', '.git', 'log', 'bin');
protected $excludedExts = array('ini', 'jpg', 'png', 'gif', 'swf', 'jar', 'ico', 'psd', 'swc', 'keystore');
protected $excludedFiles = array('.DS_Store', '.htaccess');
protected $excludedDirs = array('_build', '_test', '.git', 'bin', 'build', 'data', 'library', 'log', 'tmp');
protected $excludedExts = array('gif', 'ico', 'ini', 'jar', 'jpeg', 'jpg', 'keystore', 'png', 'psd', 'swc', 'swf');
protected $excludedFiles = array('.DS_Store', '.htaccess', '.gitignore', '.travis.yml');

/**
* return true if the string is UTF8 encoded.
Expand Down
3 changes: 1 addition & 2 deletions tests/phpunit.xml
Expand Up @@ -7,7 +7,6 @@
<directory suffix=".php">../core/controllers</directory>
<directory suffix=".php">../core/models/pdo</directory>
<directory suffix=".php">../core/models/dao</directory>
<directory suffix=".php">../library/MIDAS</directory>
<exclude>
<file>../core/Bootstrap.php</file>
<file>../core/controllers/ErrorController.php</file>
Expand All @@ -25,4 +24,4 @@
<log type="junit" target="./log/junit.xml" logIncompleteSkipped="false"/>
<log type="json" target="./log/json.txt" logIncompleteSkipped="false"/>
</logging>
</phpunit>
</phpunit>
1 change: 0 additions & 1 deletion tests/styleCheck.php
Expand Up @@ -32,7 +32,6 @@
$toTest .= TEST_DIR.'/../core/include.php,';
$toTest .= TEST_DIR.'/../index.php,';
$toTest .= TEST_DIR.'/../core/models,';
$toTest .= TEST_DIR.'/../library/MIDAS,';
$toTest .= TEST_DIR.'/../core/controllers';
$_SERVER['argv'][2] = $toTest;
$_SERVER['argv'][3] = '--outdir';
Expand Down

0 comments on commit 983967c

Please sign in to comment.