| | 666 | /** |
| | 667 | * @ticket 25435 |
| | 668 | */ |
| | 669 | public function test_do_single_shortcode_no_atts_self_closing_test_args_only() { |
| | 670 | do_single_shortcode( 'test-shortcode-tag' ); |
| | 671 | |
| | 672 | $this->assertSame( 'test-shortcode-tag', $this->tagname ); |
| | 673 | $this->assertSame( array(), $this->atts ); |
| | 674 | $this->assertSame( null, $this->content ); |
| | 675 | } |
| | 676 | |
| | 677 | /** |
| | 678 | * @ticket 25435 |
| | 679 | */ |
| | 680 | public function test_do_single_shortcode_no_atts_self_closing_output() { |
| | 681 | $out = do_single_shortcode( 'dumptag-and-content' ); |
| | 682 | $this->assertSame( 'content = [dumptag-and-content]', $out ); |
| | 683 | } |
| | 684 | |
| | 685 | /** |
| | 686 | * @ticket 25435 |
| | 687 | */ |
| | 688 | public function test_do_single_shortcode_no_atts_with_content_test_args_only() { |
| | 689 | do_single_shortcode( 'test-shortcode-tag', array(), 'Foo Content' ); |
| | 690 | |
| | 691 | $this->assertSame( 'test-shortcode-tag', $this->tagname ); |
| | 692 | $this->assertSame( array(), $this->atts ); |
| | 693 | $this->assertSame( 'Foo Content', $this->content ); |
| | 694 | } |
| | 695 | |
| | 696 | /** |
| | 697 | * @ticket 25435 |
| | 698 | */ |
| | 699 | public function test_do_single_shortcode_no_atts_with_content_output() { |
| | 700 | $out = do_single_shortcode( 'dumptag-and-content', array(), 'Foo Content' ); |
| | 701 | |
| | 702 | $this->assertSame( 'content = [dumptag-and-content]Foo Content[/dumptag-and-content]', $out ); |
| | 703 | } |
| | 704 | |
| | 705 | /** |
| | 706 | * @ticket 25435 |
| | 707 | */ |
| | 708 | public function test_do_single_shortcode_with_atts_self_closing_args_only() { |
| | 709 | $atts = array( 'foo' => 'bar', 'baz' => 'bot' ); |
| | 710 | |
| | 711 | do_single_shortcode( 'test-shortcode-tag', $atts ); |
| | 712 | |
| | 713 | $this->assertSame( 'test-shortcode-tag', $this->tagname ); |
| | 714 | $this->assertSame( $atts, $this->atts ); |
| | 715 | $this->assertSame( null, $this->content ); |
| | 716 | } |
| | 717 | |
| | 718 | /** |
| | 719 | * @ticket 25435 |
| | 720 | */ |
| | 721 | public function test_do_single_shortcode_with_atts_self_closing_ouput() { |
| | 722 | $atts = array( 'foo' => 'bar', 'baz' => 'bot' ); |
| | 723 | |
| | 724 | $out = do_single_shortcode( 'dumptag-and-content', $atts ); |
| | 725 | |
| | 726 | $this->assertSame( "content = [dumptag-and-content foo='bar' baz='bot']", $out ); |
| | 727 | } |
| | 728 | |
| | 729 | /** |
| | 730 | * @ticket 25435 |
| | 731 | */ |
| | 732 | public function test_do_single_shortcode_with_atts_with_content_args_only() { |
| | 733 | $atts = array( 'foo' => 'bar', 'baz' => 'bot' ); |
| | 734 | |
| | 735 | do_single_shortcode( 'test-shortcode-tag', $atts, 'Foo Content' ); |
| | 736 | |
| | 737 | $this->assertSame( 'test-shortcode-tag', $this->tagname ); |
| | 738 | $this->assertEqualSets( $atts, $this->atts ); |
| | 739 | $this->assertSame( 'Foo Content', $this->content ); |
| | 740 | } |
| | 741 | |
| | 742 | /** |
| | 743 | * @ticket 25435 |
| | 744 | */ |
| | 745 | public function test_do_single_shortcode_with_atts_with_content_output() { |
| | 746 | $atts = array( 'foo' => 'bar', 'baz' => 'bot' ); |
| | 747 | |
| | 748 | $out = do_single_shortcode( 'dumptag-and-content', $atts, 'Foo Content' ); |
| | 749 | |
| | 750 | $this->assertSame( "content = [dumptag-and-content foo='bar' baz='bot']Foo Content[/dumptag-and-content]", $out ); |
| | 751 | } |
| | 752 | |
| | 753 | /** |
| | 754 | * @ticket 25435 |
| | 755 | */ |
| | 756 | public function test_do_single_shortcode_expect_WP_Error_for_invalid_tag() { |
| | 757 | $out = do_single_shortcode( 'not-a-real-tag' ); |
| | 758 | |
| | 759 | $this->assertWPError( $out ); |
| | 760 | $this->assertSame( 'shortcode_invalid_tag', $out->get_error_code() ); |
| | 761 | } |
| | 762 | |
| | 763 | /** |
| | 764 | * @ticket 25435 |
| | 765 | */ |
| | 766 | public function test_do_single_shortcode_expect_WP_Error_for_invalid_callback() { |
| | 767 | // Add to the array so it'll be unset on tearDown(). |
| | 768 | $this->shortcodes[] = 'real-tag-fake-callback'; |
| | 769 | |
| | 770 | add_shortcode( 'real-tag-fake-callback', 'fake_callback' ); |
| | 771 | $out = do_single_shortcode( 'real-tag-fake-callback' ); |
| | 772 | |
| | 773 | $this->assertWPError( $out ); |
| | 774 | $this->assertSame( 'shortcode_invalid_callback', $out->get_error_code() ); |
| | 775 | } |