public function testJSONErrorsWarn()
{
$this->settings->set('component_alerts', 'none');
$this->settings->set('json_alerts', 'warn');
$response = $this->dummy_response();
$api = $this->prophet->prophesize('\\Apple_Push_API\\API');
$api->post_article_to_channel(Argument::cetera())->willReturn($response)->shouldBeCalled();
// 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' => 'ÂÂîî'));
$action = new Push($this->settings, $post_id);
$action->set_api($api->reveal());
$action->perform();
// 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 JSON errors were detected: Invalid unicode character sequences were found that could cause display issues on Apple News: ÂÂîî', $component_notice['message']);
// The post was still sent to Apple News
$this->assertEquals($response->data->id, get_post_meta($post_id, 'apple_news_api_id', true));
$this->assertEquals($response->data->createdAt, get_post_meta($post_id, 'apple_news_api_created_at', true));
$this->assertEquals($response->data->modifiedAt, get_post_meta($post_id, 'apple_news_api_modified_at', true));
$this->assertEquals($response->data->shareUrl, get_post_meta($post_id, 'apple_news_api_share_url', true));
$this->assertEquals(null, get_post_meta($post_id, 'apple_news_api_deleted', true));
}