PageRenderTime 31ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/inc/kirki/tests/test-deprecated.php

https://gitlab.com/aristath/mdl
PHP | 55 lines | 47 code | 8 blank | 0 comment | 0 complexity | c2b6d0108885bcb584d4f28596d4f961 MD5 | raw file
  1. <?php
  2. class Test_Kirki_Deprecated extends WP_UnitTestCase {
  3. public function add_theme_mod_field() {
  4. Kirki::add_field( '', array(
  5. 'type' => 'text',
  6. 'settings' => 'the_mod_option',
  7. 'section' => 'my_section',
  8. 'default' => 'foo',
  9. 'priority' => 20,
  10. 'option_type' => 'theme_mod',
  11. ) );
  12. }
  13. public function test_kirki_get_option() {
  14. $this->add_theme_mod_field();
  15. $this->assertEquals( 'foo', kirki_get_option( 'the_mod_option' ) );
  16. set_theme_mod( 'the_mod_option', 'bar' );
  17. $this->assertEquals( 'bar', kirki_get_option( 'the_mod_option' ) );
  18. }
  19. public function test_kirki_sanitize_hex() {
  20. $random_color = str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
  21. $this->assertEquals( kirki_sanitize_hex( $random_color ), Kirki_Color::sanitize_hex( $random_color ) );
  22. }
  23. public function test_kirki_get_rgb() {
  24. $random_color = str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
  25. $this->assertEquals( kirki_get_rgb( $random_color ), Kirki_Color::get_rgb( $random_color ) );
  26. }
  27. public function test_kirki_get_rgba() {
  28. $random_color = str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
  29. $this->assertEquals( kirki_get_rgba( $random_color ), Kirki_Color::get_rgba( $random_color ) );
  30. }
  31. public function test_kirki_get_brightness() {
  32. $random_color = str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
  33. $this->assertEquals( kirki_get_brightness( $random_color ), Kirki_Color::get_brightness( $random_color ) );
  34. }
  35. public function test_kirki_fonts() {
  36. $this->assertEquals( Kirki_Fonts::get_all_fonts(), Kirki_Toolkit::fonts()->get_all_fonts() );
  37. $this->assertEquals( Kirki_Fonts::get_font_choices(), Kirki_Toolkit::fonts()->get_font_choices() );
  38. $this->assertEquals( Kirki_Fonts::is_google_font( 'Open Sans' ), Kirki_Toolkit::fonts()->is_google_font( 'Open Sans' ) );
  39. $this->assertEquals( Kirki_Fonts::get_google_font_uri( array( 'Roboto' ) ), Kirki_Toolkit::fonts()->get_google_font_uri( array( 'Roboto' ) ) );
  40. $this->assertEquals( Kirki_Fonts::get_google_font_subsets(), Kirki_Toolkit::fonts()->get_google_font_subsets() );
  41. $this->assertEquals( Kirki_Fonts::choose_google_font_variants( 'Roboto' ), Kirki_Toolkit::fonts()->choose_google_font_variants( 'Roboto' ) );
  42. $this->assertEquals( Kirki_Fonts::get_standard_fonts(), Kirki_Toolkit::fonts()->get_standard_fonts() );
  43. $this->assertEquals( Kirki_Fonts::get_font_stack( '' ), Kirki_Toolkit::fonts()->get_font_stack( '' ) );
  44. $this->assertEquals( Kirki_Fonts::sanitize_font_choice( '' ), Kirki_Toolkit::fonts()->sanitize_font_choice( '' ) );
  45. $this->assertEquals( Kirki_Fonts::get_google_fonts(), Kirki_Toolkit::fonts()->get_google_fonts() );
  46. }
  47. }