Elgg\EntityIconServiceTest::testIconDimensionsAfterResize PHP Метод

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

public testIconDimensionsAfterResize ( $sw, $sh, $size, $ew, $eh, $crop, $cw = null, $ch = null )
    public function testIconDimensionsAfterResize($sw, $sh, $size, $ew, $eh, $crop, $cw = null, $ch = null)
    {
        $service = $this->createService();
        $file = new \ElggFile();
        $file->owner_guid = 1;
        $file->setFilename("{$sw}x{$sh}.jpg");
        $file->mimetype = 'image/jpeg';
        if ($crop) {
            $coords = ['x1' => 5, 'y1' => 5, 'x2' => 25, 'y2' => 25];
        } else {
            $coords = ['x1' => 0, 'y1' => 0, 'x2' => 0, 'y2' => 0];
        }
        if (!$cw) {
            $cw = $ew;
        }
        if (!$ch) {
            $ch = $eh;
        }
        // resizing
        $service->saveIconFromElggFile($this->entity, $file, 'icon');
        $icon = $service->getIcon($this->entity, $size);
        $this->assertTrue($icon->exists());
        $image_size = getimagesize($icon->getFilenameOnFilestore());
        $this->assertEquals($ew, $image_size[0]);
        $this->assertEquals($eh, $image_size[1]);
        // cropping
        $master = $service->getIcon($this->entity, 'master');
        $service->saveIconFromElggFile($this->entity, $master, 'icon', $coords);
        $icon = $service->getIcon($this->entity, $size);
        $this->assertTrue($icon->exists());
        $image_size = getimagesize($icon->getFilenameOnFilestore());
        $this->assertEquals($cw, $image_size[0]);
        $this->assertEquals($ch, $image_size[1]);
    }