to_array() public méthode

This will go through sanitize_text_field later as part of the assembled JSON. Therefore, tags aren't valid but we need to catch them now or we could encounter a parsing error when it's already too late. We also can't do this sooner, such as in build, because at that point the component could still contain nested, valid tags. We don't want to modify the JSON since it will still undergo further processing. We only want to check if, on its own, this component would end up empty.
public to_array ( ) : array
Résultat array
 public function testFilter()
 {
     $this->settings->set('initial_dropcap', 'no');
     $body_component = new Body('<p>my text</p>', null, $this->settings, $this->styles, $this->layouts);
     add_filter('apple_news_body_json', function ($json) {
         $json['textStyle'] = 'fancy-body';
         return $json;
     });
     $this->assertEquals(array('text' => "my text\n\n", 'role' => 'body', 'format' => 'markdown', 'textStyle' => 'fancy-body', 'layout' => 'body-layout'), $body_component->to_array());
 }