save transcript

This commit is contained in:
John Bintz 2009-08-09 12:39:52 -04:00
parent db0e182bbf
commit 60b9e24d3f
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,17 @@
<?php
/**
* WhatDidTheySay manages transcriptions that are attached as metadata
* individual posts. Transcriptions can be updated, deleted, and moved to
* other posts as necessary.
*/
class WhatDidTheySay {
function save_transcript($post_id, $language, $transcript) {
$current_transcripts = get_post_meta($post_id, "provided_transcripts", true);
if (!is_array($current_transcripts)) { $current_transcripts = array(); }
$current_transcripts[$language] = $transcript;
return update_post_meta($post_id, "provided_transcripts", $current_transcripts);
}
}
?>

View File

@ -0,0 +1,24 @@
<?php
require_once('PHPUnit/Framework.php');
require_once(dirname(__FILE__) . '/../../mockpress/mockpress.php');
require_once(dirname(__FILE__) . '/../classes/WhatDidTheySay.php');
class WhatDidTheySayTest extends PHPUnit_Framework_TestCase {
function setUp() {
$this->what = new WhatDidTheySay();
}
function testSaveTranscription() {
$this->what->save_transcript(1, "en", "This is a transcript");
$this->assertEquals(array("en" => "This is a transcript"), get_post_meta(1, "provided_transcripts", true));
$this->what->save_transcript(1, "en", "this is a new transcript");
$this->assertEquals(array("en" => "this is a new transcript"), get_post_meta(1, "provided_transcripts", true));
$this->what->save_transcript(1, "fr", "il s'agit d'une nouvelle transcription");
$this->assertEquals(array("en" => "this is a new transcript", "fr" => "il s'agit d'une nouvelle transcription"), get_post_meta(1, "provided_transcripts", true));
}
}
?>