/**
  * Integration.
  */
 function testPerformImport()
 {
     $admin = $this->getMock('WhatDidTheySayAdmin', array('_get_transcript_posts'));
     $admin->_import_chunk_size = 1;
     wp_insert_user(array('ID' => 1));
     wp_set_current_user(1);
     _set_user_capabilities('approve_transcriptions');
     for ($i = 1; $i <= 2; ++$i) {
         wp_insert_post(array('ID' => $i));
         update_post_meta($i, "transcript", "this is my transcript");
     }
     $admin->expects($this->once())->method('_get_transcript_posts')->will($this->returnValue(array(1, 2)));
     $this->assertEquals(1, $admin->import_transcripts('en'));
     $this->assertEquals('', get_post_meta(1, "transcript", true));
     $this->assertEquals('this is my transcript', get_post_meta(2, "transcript", true));
     $this->assertEquals(array(array('language' => 'en', 'transcript' => 'this is my transcript', 'user_id' => 1, 'key' => 0)), get_post_meta(1, 'approved_transcripts', true));
     delete_post_meta(2, 'transcript');
     $admin = $this->getMock('WhatDidTheySayAdmin', array('_get_transcript_posts'));
     $admin->_import_chunk_size = 1;
     $admin->expects($this->once())->method('_get_transcript_posts')->will($this->returnValue(array()));
     $this->assertEquals(0, $admin->import_transcripts('en'));
 }
Exemple #2
0
 /**
  * @dataProvider providerTestCurrentUserCan
  */
 function testCurrentUserCan($capabilities, $expected_result)
 {
     _set_user_capabilities('one', 'two');
     $this->assertEquals($expected_result, call_user_func_array('current_user_can', $capabilities));
 }