[ Index ] |
PHP Cross Reference of GlotPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 class GP_Test_Misc extends GP_UnitTestCase { 4 5 function test_gp_array_flatten() { 6 $this->assertEquals( array(), gp_array_flatten( array() ) ); 7 $this->assertEquals( array( 1, 2, 3 ), gp_array_flatten( array( 1, array( 2, 3 ) ) ) ); 8 $this->assertEquals( array( 1, 2, 3, 4, 5, 6, 7 ), gp_array_flatten( array( 1, array( 2, array( 3, 4 ), 5, ), 6, array( 7 ) ) ) ); 9 } 10 11 function test_gp_array_zip() { 12 $this->assertEquals( array(), gp_array_zip() ); 13 $this->assertEquals( array(), gp_array_zip( array() ) ); 14 $this->assertEquals( array(), gp_array_zip( array(), array(), array() ) ); 15 $this->assertEquals( array( array('baba') ), gp_array_zip( array('baba') ) ); 16 $this->assertEquals( array(), gp_array_zip( array('baba'), array(), array() ) ); 17 $this->assertEquals( array( array('baba', 'dyado') ), gp_array_zip( array('baba'), array('dyado') ) ); 18 $this->assertEquals( array( array('baba', 'dyado') ), gp_array_zip( array('baba', 'boom'), array('dyado') ) ); 19 $this->assertEquals( array( array( array('baba'), 'dyado') ), gp_array_zip( array( array('baba'), 'boom'), array('dyado') ) ); 20 } 21 22 function test_gp_array_any() { 23 $this->assertEquals( false, gp_array_any( 'intval', array( 0 ) ) ); 24 $this->assertEquals( false, gp_array_any( '__return_false', array( 1, 2, 3, 4 ) ) ); 25 $this->assertEquals( false, gp_array_any( '__return_true', array() ) ); 26 $this->assertEquals( true, gp_array_any( '__return_true', array( 1, 2, 3, 4 ) ) ); 27 $this->assertEquals( true, gp_array_any( function ( $x ) { 28 return $x % 2; 29 }, array( 1, 2, 3, 4 ) ) ); 30 } 31 32 function test_gp_object_has_var_returs_true_if_var_is_null() { 33 $this->assertTrue( gp_object_has_var( (object)array( 'baba' => null), 'baba' ) ); 34 } 35 36 function test_gp_get_import_file_format() { 37 // Test to make sure we detect each file format extension correctly. 38 foreach( GP::$formats as $format ) { 39 foreach( $format->get_file_extensions() as $extension ) { 40 $this->assertEquals( $format, gp_get_import_file_format( null, 'filename.' . $extension ) ); 41 } 42 } 43 44 // Test to make sure we don't auto detect if a known file format is passed in. 45 $this->assertEquals( GP::$formats[ 'po' ], gp_get_import_file_format( 'po', 'filename.strings' ) ); 46 47 // Test to make sure we return null when no file format is found. 48 $this->assertEquals( null, gp_get_import_file_format( 'thiswillneverbeafileformat', 'filename.thiswillneverbeafileformat' ) ); 49 $this->assertEquals( null, gp_get_import_file_format( null, 'filename.thiswillneverbeafileformat' ) ); 50 } 51 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:01:07 2024 | Cross-referenced by PHPXref 0.7.1 |