| | 788 | |
| | 789 | /** |
| | 790 | * @ticket BP8236 |
| | 791 | */ |
| | 792 | public function test_save_activity_requires_component() { |
| | 793 | $a = bp_activity_add( |
| | 794 | array( |
| | 795 | 'component' => '', |
| | 796 | 'content' => 'Activity without component content %s', |
| | 797 | 'type' => 'activity_update', |
| | 798 | 'error_type' => 'wp_error', |
| | 799 | ) |
| | 800 | ); |
| | 801 | |
| | 802 | $this->assertInstanceOf( 'WP_Error', $a ); |
| | 803 | $this->assertEquals( 'bp_activity_missing_component', $a->get_error_code() ); |
| | 804 | } |
| | 805 | |
| | 806 | /** |
| | 807 | * @ticket BP8236 |
| | 808 | */ |
| | 809 | public function test_save_activity_requires_type() { |
| | 810 | $a = bp_activity_add( |
| | 811 | array( |
| | 812 | 'component' => 'foobar', |
| | 813 | 'content' => 'Activity without type content %s', |
| | 814 | 'type' => '', |
| | 815 | 'error_type' => 'wp_error', |
| | 816 | ) |
| | 817 | ); |
| | 818 | |
| | 819 | $this->assertInstanceOf( 'WP_Error', $a ); |
| | 820 | $this->assertEquals( 'bp_activity_missing_type', $a->get_error_code() ); |
| | 821 | } |
| | 822 | |
| | 823 | /** |
| | 824 | * @ticket BP8236 |
| | 825 | */ |
| | 826 | public function test_save_activity_requires_content() { |
| | 827 | $a = bp_activity_add( |
| | 828 | array( |
| | 829 | 'component' => buddypress()->activity->id, |
| | 830 | 'content' => '', |
| | 831 | 'type' => 'activity_update', |
| | 832 | 'error_type' => 'wp_error', |
| | 833 | ) |
| | 834 | ); |
| | 835 | |
| | 836 | $this->assertInstanceOf( 'WP_Error', $a ); |
| | 837 | $this->assertEquals( 'bp_activity_missing_content', $a->get_error_code() ); |
| | 838 | } |
| | 839 | |
| | 840 | /** |
| | 841 | * @ticket BP8236 |
| | 842 | */ |
| | 843 | public function test_save_activity_does_not_require_content() { |
| | 844 | $a = bp_activity_add( |
| | 845 | array( |
| | 846 | 'component' => buddypress()->members->id, |
| | 847 | 'content' => '', |
| | 848 | 'type' => 'new_member', |
| | 849 | 'error_type' => 'wp_error', |
| | 850 | ) |
| | 851 | ); |
| | 852 | |
| | 853 | $this->assertFalse( is_wp_error( $a ) ); |
| | 854 | } |
| | 855 | |
| | 856 | /** |
| | 857 | * @ticket BP8236 |
| | 858 | */ |
| | 859 | public function test_save_activity_custom_type_requires_content() { |
| | 860 | add_filter( 'bp_activity_type_requires_content', '__return_true' ); |
| | 861 | |
| | 862 | $a = bp_activity_add( |
| | 863 | array( |
| | 864 | 'component' => 'foo', |
| | 865 | 'content' => '', |
| | 866 | 'type' => 'bar', |
| | 867 | 'error_type' => 'wp_error', |
| | 868 | ) |
| | 869 | ); |
| | 870 | |
| | 871 | remove_filter( 'bp_activity_type_requires_content', '__return_true' ); |
| | 872 | |
| | 873 | $this->assertInstanceOf( 'WP_Error', $a ); |
| | 874 | $this->assertEquals( 'bp_activity_missing_content', $a->get_error_code() ); |
| | 875 | } |