Elgg\EntityIconServiceTest::testCanSaveIconFromElggFile PHP Method

testCanSaveIconFromElggFile() public method

    public function testCanSaveIconFromElggFile()
    {
        $service = $this->createService();
        $file = new \ElggFile();
        $file->owner_guid = 1;
        $file->setFilename('400x300.gif');
        $file->mimetype = 'image/gif';
        $service->saveIconFromElggFile($this->entity, $file);
        $this->assertTrue($service->hasIcon($this->entity, 'master'));
        $this->assertTrue($service->hasIcon($this->entity, 'large'));
        $this->assertTrue($service->hasIcon($this->entity, 'medium'));
        $this->assertTrue($service->hasIcon($this->entity, 'small'));
        $this->assertTrue($service->hasIcon($this->entity, 'tiny'));
        $this->assertTrue($service->hasIcon($this->entity, 'topbar'));
        // make sure we removed temporary files
        $dir_items = scandir($this->entity_dir_path . 'tmp');
        $this->assertTrue(count($dir_items) <= 2);
    }