PHP Classes

File: tests/TranslatorTest.php

Recommend this page to a friend!
  Classes of mohammad anzawi   PHP Multilingual Support Library   tests/TranslatorTest.php   Download  
File: tests/TranslatorTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Multilingual Support Library
Translate texts for Web sites from JSON or DB
Author: By
Last change:
Date: 3 years ago
Size: 1,642 bytes
 

Contents

Class file image Download
<?php

use PHPtricks\Logaty\App;
use
PHPUnit\Framework\TestCase;

class
TranslatorTest extends TestCase
{

    protected
$_defaultLanguage;
    protected
$_currentLanguage;

    protected function
setUp() : void
   
{
       
$this->_defaultLanguage = logaty()->defaultLang();
       
$this->_currentLanguage = logaty()->current();
        if (
$this->_currentLanguage === $this->_defaultLanguage)
           
$this->_currentLanguage = 'ar';
    }

   
/** @test */
   
public function logaty_is_instance_of_app_class()
    {
       
$this->assertInstanceOf(App::class, logaty());
    }

   
/** @test */
   
public function we_can_translate_string_to_current_language()
    {
       
$translate = logaty('home.test', $this->_currentLanguage);

       
$this->assertEquals($translate,'?? ??????');
    }

   
/** @test */
   
public function we_can_translate_string_to_default_language()
    {
       
$translate = logaty('home.test', $this->_defaultLanguage);

       
$this->assertEquals($translate,'Test String');
    }

   
/** @test */
   
public function we_can_translate_string_with__x_method()
    {
       
$translate = logaty()->_x('home.test');

       
$this->assertIsString($translate,'Test String');
    }

   
/** @test */
   
public function if_we_send_unexists_translate_returns_same_sent_string()
    {
       
$translate = logaty('file.not-exists');

       
$this->assertEquals($translate,'file.not-exists');
    }

   
/** @test */
   
public function we_can_translate_string_with_specified_language()
    {
       
$translate = logaty('file.not-exists', 'ru');

       
$this->assertIsString($translate);
    }
}