Admin_Action_Index_Push_Test::testComponentErrorsFail PHP Метод

testComponentErrorsFail() публичный Метод

    public function testComponentErrorsFail()
    {
        $this->settings->set('component_alerts', 'fail');
        $this->settings->set('json_alerts', 'none');
        $response = $this->dummy_response();
        $api = $this->prophet->prophesize('\\Apple_Push_API\\API');
        $api->post_article_to_channel(Argument::cetera())->willReturn($response)->shouldNotBeCalled();
        // We need to create an iframe, so run as administrator
        $user_id = $this->set_admin();
        // Create post
        $post_id = $this->factory->post->create(array('post_content' => '<p><iframe width="460" height="460" src="http://unsupportedservice.com/embed.html?video=1232345&autoplay=0" frameborder="0" allowfullscreen></iframe></p>'));
        $action = new Push($this->settings, $post_id);
        $action->set_api($api->reveal());
        try {
            $action->perform();
        } catch (Action_Exception $e) {
            // An admin error notice was created
            $notices = get_user_meta($user_id, 'apple_news_notice', true);
            $this->assertNotEmpty($notices);
            $component_notice = end($notices);
            $this->assertEquals('The following components are unsupported by Apple News and prevented publishing: iframe', $e->getMessage());
            // The post was not sent to Apple News
            $this->assertEquals(null, get_post_meta($post_id, 'apple_news_api_id', true));
            $this->assertEquals(null, get_post_meta($post_id, 'apple_news_api_created_at', true));
            $this->assertEquals(null, get_post_meta($post_id, 'apple_news_api_modified_at', true));
            $this->assertEquals(null, get_post_meta($post_id, 'apple_news_api_share_url', true));
            $this->assertEquals(null, get_post_meta($post_id, 'apple_news_api_deleted', true));
        }
    }