[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/tests/phpunit/testcases/tests_things/ -> test_thing_note.php (source)

   1  <?php
   2  
   3  class GP_Test_Note extends GP_UnitTestCase {
   4  
   5  	function setUp() {
   6          parent::setUp();
   7          $this->route = new GP_Route_Note;
   8          $this->notes = new GP_Note;
   9      }
  10  
  11  	function test_save() {
  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['original_id'] = $original->id;
  26          $_POST['note'] = 'Hey I am a note!';
  27  
  28          $note = $this->notes->save();
  29  
  30          $this->assertEquals( $note->note, $_POST['note'] );
  31          $this->assertEquals( $note->translation_id, $_POST['translation_id'] );
  32          $this->assertEquals( $note->original_id, $_POST['original_id'] );
  33      }
  34  
  35  	function test_edit() {
  36          $this->set_admin_user_as_current();
  37  
  38          $set = $this->factory->translation_set->create_with_project_and_locale();
  39          $original = $this->factory->original->create( array( 'project_id' => $set->project->id, 'status' => '+active', 'singular' => 'baba' ) );
  40  
  41          $translation = $this->factory->translation->create( array(
  42              'translation_set_id' => $set->id,
  43              'original_id'        => $original->id,
  44              'status'             => 'current',
  45          ) );
  46          $translation->set_as_current();
  47  
  48          $_POST['translation_id'] = $translation->id;
  49          $_POST['original_id'] = $original->id;
  50          $_POST['note'] = 'Hey I am a note!';
  51  
  52          $note = $this->notes->save();
  53  
  54          $note_content = 'Hey I am a note edited!';
  55          $note = $this->notes->edit( $note->id, $note_content, $translation );
  56  
  57          $this->assertEquals( $note->note, $note_content );
  58          $this->assertEquals( $note->translation_id, $_POST['translation_id'] );
  59          $this->assertEquals( $note->original_id, $_POST['original_id'] );
  60      }
  61  }


Generated: Tue Dec 10 01:02:00 2019 Cross-referenced by PHPXref 0.7.1