/**
  * @see \ResponsiveImages\SrcsetGeneratorInterface
  *
  * @param string    $uri
  *   Drupal URI to the original image file.
  * @param RImg\Size $size
  *
  * @return RImg\Src[]
  */
 public function listFor($uri, RImg\Size $size)
 {
     $styles = $this->stylesMatchingSize($size);
     # By default Drupal doesn't provide an image style that crops an image to
     # an aspect ratio without potentially upscaling it. If the original image is
     # smaller than the styles that are returned we aren't providing any better
     # quality. Better to just allow only one larger than the original, or even
     # the original if it matches the aspect ratio.
     $image = image_get_info($uri);
     if ($image) {
         $styles = F\partition($styles, function ($style) use($image, $size) {
             return $style->width < $image['width'];
         });
         if ($size->matchesAspectRatio($image['width'] / $image['height']) and (!empty($styles[1]) and F\head($styles[1])->width != $image['width'] or $image['width'] <= $size->getMaxWidth() * 2)) {
             $styles[0][] = (object) ['name' => null, 'width' => $image['width'], 'height' => $image['height'], 'firm' => true];
         } else {
             if (!empty($styles[1])) {
                 $styles[0][] = F\head($styles[1]);
             }
         }
         $styles = $styles[0];
     }
     return F\map($styles, function ($style) use($uri) {
         $url = $style->name ? image_style_url($style->name, $uri) : file_create_url($uri);
         return new RImg\Src($url, $style->width);
     });
 }
 /**
  * tests get_activity_tree returns unavailable activities (that are configured to be visible)
  * @global moodle_database $DB
  */
 public function test_get_activity_tree_returns_unavailable_activities()
 {
     global $DB;
     $activity_tree = B\get_activity_tree(get_fast_modinfo($this->_course), -1, context_course::instance($this->_course->id));
     // get the section id (as opposed to the section number) of section number three
     $three = 3;
     $section_id = (int) $DB->get_field('course_sections', 'id', ['course' => $this->_course->id, 'section' => $three]);
     // there are two (unavailable) activities in section three
     $this->assertEquals(2, $DB->count_records('course_modules', ['course' => $this->_course->id, 'section' => $section_id]));
     // however, there is only one visible activity in section three
     $this->assertCount(1, $activity_tree[$three]->activities);
     $this->assertEquals($this->_quiz->cmid, F\head($activity_tree[$three]->activities)->id);
     $this->assertFalse(F\head($activity_tree[$three]->activities)->available);
 }