save transcript
This commit is contained in:
parent
db0e182bbf
commit
60b9e24d3f
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue