function test_pmp_enclosures_for_media()
 {
     $new_post = $this->factory->post->create();
     $url = 'http://publicmediaplatform.org/wp-content/uploads/logo1.png';
     $desc = 'Test description';
     $image_id = pmp_media_sideload_image($url, $new_post, $desc);
     $enclosures = pmp_enclosures_for_media($image_id);
     $this->assertTrue((bool) count($enclosures));
     $first_enc = $enclosures[0];
     // These should be present at the first level of the returned array
     $expected_keys_first = array('href', 'meta', 'type');
     foreach ($expected_keys_first as $expected_key) {
         $this->assertTrue(in_array($expected_key, array_keys((array) $first_enc)));
     }
     // The meta array should have these keys, indicating the crop and size of the image
     $expected_keys_second = array('crop', 'width', 'height');
     foreach ($expected_keys_second as $expected_key) {
         $this->assertTrue(in_array($expected_key, array_keys((array) $first_enc->meta)));
     }
     // Make sure the 'crop' value is set using PMP best practices
     // See: https://support.pmp.io/docs#best-practices-image-crops
     $pmp_image_crops = array('primary', 'large', 'medium', 'small', 'square');
     foreach ($enclosures as $enc) {
         $this->assertTrue(in_array($enc->meta->crop, $pmp_image_crops));
     }
 }
 /**
  * Turn a post into a media-doc
  */
 protected function set_doc_data()
 {
     parent::set_doc_data();
     // set profile link
     $profile = $this->post_profile_type();
     $this->doc->links->profile = $this->get_profile_links($profile);
     // media fields
     if (!empty($this->post->post_excerpt)) {
         $this->doc->attributes->description = $this->post->post_excerpt;
     }
     if (!empty($this->post_meta['pmp_byline'])) {
         $this->doc->attributes->byline = $this->post_meta['pmp_byline'];
     }
     $this->doc->links->alternate = array((object) array('href' => get_permalink($this->post->ID), 'type' => 'text/html'));
     // media sub-profile fields
     if ($profile == 'image') {
         $alt_text = get_post_meta($this->post->ID, '_wp_attachment_image_alt', true);
         if (!empty($alt_text)) {
             $this->doc->attributes->title = $alt_text;
         }
         $this->doc->links->enclosure = pmp_enclosures_for_media($this->post->ID);
     } else {
         if ($profile == 'audio') {
             $this->doc->links->enclosure = pmp_enclosures_for_audio($this->post->ID);
         }
     }
 }