Commit f1775973 authored by Robert Lyon's avatar Robert Lyon

Bug 1810990: Allowing the uploading of archive file in behat

And have it treated as an archive

Change-Id: I74ae535ad4a9e104049d3feb80f5452c8fa2aebb
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 5bff19e5
......@@ -229,9 +229,17 @@ EOD;
*/
public static function get_mimetype($filename) {
$path = get_mahararoot_dir() . '/test/behat/upload_files/' . $filename;
$mimetype = mime_content_type($path);
$mimetype = file_mime_type($path);
list($media, $ext) = explode('/', $mimetype);
$mediatype = ($media == 'application' || $media == 'text') ? 'attachment' : $media;
if ($media == 'application') {
$mediatype = 'archive';
}
else if ($media == 'text') {
$mediatype = 'attachment';
}
else {
$mediatype = $media;
}
return $mediatype;
}
......@@ -264,7 +272,7 @@ EOD;
* @return int $artefactid of the newly created artefact
*/
public static function process_attachment($filename, $ownertype, $ownerid, $parentid=null) {
$mediatype = self:: get_mimetype($filename);
$mediatype = self::get_mimetype($filename);
// we need to find the id of the item we are trying to attach and save it as artefactid
if (!isset($parentid)) {
$dbownertype = $ownertype == 'user' ? 'owner' : $ownertype;
......@@ -1789,7 +1797,6 @@ EOD;
$artefact->title = $file;
switch ($ownertype) {
case 'user':
$artefact->user = 1;
$artefact->owner = $ownerid;
break;
case 'institution':
......@@ -1805,7 +1812,7 @@ EOD;
$artefact->author = $ownerid;
// table artefact_file_files needs this information
$artefact->contenthash = ArtefactTypeFile::generate_content_hash($path);
$artefact->filetype = mime_content_type($path);
$artefact->filetype = file_mime_type($path);
$now = date("Y-m-d H:i:s");
$artefact->atime = $artefact->ctime = $artefact->mtime =$now;
......@@ -1837,6 +1844,12 @@ EOD;
$artefactid = $artobj->get('id');
}
if ($filetype == 'archive') {
$artobj = ArtefactTypeFile::new_file($path, $artefact);
$artobj->commit();
$artefactid = $artobj->get('id');
}
if ($filetype == 'audio') {
$artobj = ArtefactTypeFile::new_file($path, $artefact);
$artobj->commit();
......
@javascript @core @blocktype
Feature: Creating a page with blocks
Feature: Creating pages with blocks
As a user
I want to add a page with blocks as a background step
I want to add multiple pages with a selection of blocks as a background step
As a group admin
I want to add a page with blocks as a background step
......@@ -33,19 +33,19 @@ Background:
| UserB | 01/01/2018 | Germany | New Zealand | | | |
And the following "goals and skills" exist:
| user | goaltype/skilltype | title | description | attachment |
| UserA | academicgoal | fix lateness | pack bag night before | Image1.jpg |
| UserA | careergoal | meow | cat a lyst | users.csv |
| UserA | personalgoal | gym shark | do do do | Image2.png |
| UserA | academicskill | alphabet | abc | groups.csv |
| UserA | personalskill | whistle | *inset whistle noise | Image1.jpg |
| UserA | workskill | team work | axe throwing? | users.csv |
| UserB | academicgoal | academi doooo| description goal/skill| Image2.png |
| UserB | careergoal | careerg doooo| description goal/skill| groups.csv |
| UserB | personalgoal | persona doooo| description goal/skill| Image1.jpg |
| UserB | academicskill | academi doooo| description goal/skill| users.csv |
| UserB | personalskill | persona doooo| description goal/skill| Image2.png |
| UserB | workskill | workski doooo| description goal/skill| groups.csv |
| user | goaltype/skilltype | title | description | attachment |
| UserA | academicgoal | fix lateness | pack bag night before | Image1.jpg |
| UserA | careergoal | meow | cat a lyst | users.csv |
| UserA | personalgoal | gym shark | do do do | Image2.png |
| UserA | academicskill | alphabet | abc | 3images.zip |
| UserA | personalskill | whistle | *inset whistle noise | Image1.jpg |
| UserA | workskill | team work | axe throwing? | users.csv |
| UserB | academicgoal | academi doooo| description goal/skill| Image2.png |
| UserB | careergoal | careerg doooo| description goal/skill| groups.csv |
| UserB | personalgoal | persona doooo| description goal/skill| Image1.jpg |
| UserB | academicskill | academi doooo| description goal/skill| users.csv |
| UserB | personalskill | persona doooo| description goal/skill| Image2.png |
| UserB | workskill | workski doooo| description goal/skill| groups.csv |
And the following "interests" exist:
# Available fields: user*, interest*, description
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment