functions.export.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Test export functions
  4. *
  5. * @group export
  6. * @ticket 22435
  7. */
  8. class Test_WP_Export_Functions extends WP_UnitTestCase {
  9. function setUp() {
  10. if ( ! function_exists( 'wp_export' ) ) {
  11. $this->markTestSkipped( "wp_export function doesn't exist" );
  12. }
  13. parent::setUp();
  14. }
  15. function test_wp_export_returns_wp_error_if_the_writer_throws_Export_exception() {
  16. $this->assertTrue( is_wp_error( wp_export( array( 'writer' => 'Test_WP_Export_Stub_Writer_Throws_Export_Exception' ) ) ) );
  17. }
  18. function test_wp_export_passes_the_exception_if_the_writer_throws_other_exception() {
  19. $this->setExpectedException( 'Exception' );
  20. wp_export( array( 'writer' => 'Test_WP_Export_Stub_Writer_Throws_Other_Exception' ) );
  21. }
  22. }
  23. class Test_WP_Export_Stub_Writer_Throws_Export_Exception {
  24. function __construct( $formatter ) {
  25. }
  26. function export() {
  27. throw new WP_Export_Exception( 'baba' );
  28. }
  29. }
  30. class Test_WP_Export_Stub_Writer_Throws_Other_Exception {
  31. function __construct( $formatter ) {
  32. }
  33. function export() {
  34. throw new Exception( 'baba' );
  35. }
  36. }