[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/tests/phpunit/testcases/tests_routes/ -> test_route_note.php (source)

   1  <?php
   2  
   3  class GP_Test_Route_Note extends GP_UnitTestCase_Route {
   4      public $route_class = 'GP_Route_Note';
   5  
   6  	function setUp() {
   7          parent::setUp();
   8          $this->translation = new GP_Translation;
   9      }
  10  
  11  	function test_add_note_function() {
  12          $this->set_admin_user_as_current();
  13  
  14          $set = $this->factory->translation_set->create_with_project_and_locale();
  15          $original = $this->factory->original->create( array( 'project_id' => $set->project->id, 'status' => '+active', 'singular' => 'baba' ) );
  16  
  17          $translation = $this->factory->translation->create( array(
  18              'translation_set_id' => $set->id,
  19              'original_id'        => $original->id,
  20              'status'             => 'current',
  21          ) );
  22          $translation->set_as_current();
  23  
  24          $_POST['translation_id'] = $translation->id;
  25          $_POST['note'] = 'Hey I am a note!';
  26          $_REQUEST['_gp_route_nonce'] = wp_create_nonce( 'new-note-' . $translation->id );
  27  
  28          $this->route->new_post();
  29  
  30          $this->assertThereIsANoticeContaining( 'created' );
  31      }
  32  
  33  	function test_edit_note_function() {
  34          $this->set_admin_user_as_current();
  35  
  36          $set = $this->factory->translation_set->create_with_project_and_locale();
  37          $original = $this->factory->original->create( array( 'project_id' => $set->project->id, 'status' => '+active', 'singular' => 'baba' ) );
  38  
  39          $translation = $this->factory->translation->create( array(
  40              'translation_set_id' => $set->id,
  41              'original_id'        => $original->id,
  42              'status'             => 'current',
  43          ) );
  44  
  45          $_POST['translation_id'] = $translation->id;
  46          $_POST['note'] = 'Hey I am a note to edit!';
  47          $_REQUEST['_gp_route_nonce'] = wp_create_nonce( 'new-note-' . $translation->id );
  48  
  49          $note = $this->route->new_post();
  50          $_POST['note_id'] = $note->id;
  51  
  52          $_POST['note'] = 'Hey I am a note edited!';
  53          $_REQUEST['_gp_route_nonce'] = wp_create_nonce( 'edit-note-' . $_POST['note_id'] );
  54  
  55          $this->route->edit_post();
  56  
  57          $this->assertThereIsANoticeContaining( 'updated' );
  58      }
  59  
  60  	function test_delete_note_function() {
  61          $this->set_admin_user_as_current();
  62  
  63          $set = $this->factory->translation_set->create_with_project_and_locale();
  64          $original = $this->factory->original->create( array( 'project_id' => $set->project->id, 'status' => '+active', 'singular' => 'baba' ) );
  65  
  66          $translation = $this->factory->translation->create( array(
  67              'translation_set_id' => $set->id,
  68              'original_id'        => $original->id,
  69              'status'             => 'current',
  70          ) );
  71          $translation->set_as_current();
  72  
  73          $_POST['translation_id'] = $translation->id;
  74          $_POST['note'] = 'Hey I am a note to delete!';
  75          $_REQUEST['_gp_route_nonce'] = wp_create_nonce( 'new-note-' . $translation->id );
  76  
  77          $note = $this->route->new_post();
  78          $_POST['note_id'] = $note->id;
  79  
  80          $_REQUEST['_gp_route_nonce'] = wp_create_nonce( 'delete-note-' . $_POST['note_id'] );
  81  
  82          $note = $this->route->delete_post();
  83  
  84          $this->assertTrue( $note );
  85          $this->assertThereIsANoticeContaining( 'deleted' );
  86      }
  87  }


Generated: Fri Apr 17 01:01:46 2020 Cross-referenced by PHPXref 0.7.1