Вход Регистрация
Файл: gapps/vendor/fzaninotto/faker/test/Faker/Provider/ImageTest.php
Строк: 53
<?php

namespace FakerTestProvider;

use 
FakerProviderImage;

class 
ImageTest extends PHPUnit_Framework_TestCase
{
    public function 
testImageUrlUses640x680AsTheDefaultSize()
    {
        
$this->assertRegExp('#^http://lorempixel.com/640/480/#'Image::imageUrl());
    }

    public function 
testImageUrlAcceptsCustomWidthAndHeight()
    {
        
$this->assertRegExp('#^http://lorempixel.com/800/400/#'Image::imageUrl(800400));
    }

    public function 
testImageUrlAcceptsCustomCategory()
    {
        
$this->assertRegExp('#^http://lorempixel.com/800/400/nature/#'Image::imageUrl(800400'nature'));
    }

    public function 
testImageUrlAcceptsCustomText()
    {
        
$this->assertRegExp('#^http://lorempixel.com/800/400/nature/Faker#'Image::imageUrl(800400'nature'false'Faker'));
    }

    public function 
testImageUrlAddsARandomGetParameterByDefault()
    {
        
$url Image::imageUrl(800400);
        
$splitUrl preg_split('/?/'$url);

        
$this->assertEquals(count($splitUrl), 2);
        
$this->assertRegexp('#d{5}#'$splitUrl[1]);
    }

    
/**
     * @expectedException InvalidArgumentException
     */
    
public function testUrlWithDimensionsAndBadCategory()
    {
        
Image::imageUrl(800400'bullhonky');
    }

    public function 
testDownloadWithDefaults()
    {
        
$url "http://www.lorempixel.com/";
        
$curlPing curl_init($url);
        
curl_setopt($curlPingCURLOPT_TIMEOUT5);
        
curl_setopt($curlPingCURLOPT_CONNECTTIMEOUT5);
        
curl_setopt($curlPingCURLOPT_RETURNTRANSFERtrue);
        
$data curl_exec($curlPing);
        
$httpCode curl_getinfo($curlPingCURLINFO_HTTP_CODE);
        
curl_close($curlPing);

        if (
$httpCode 200 $httpCode 300) {
            
$this->markTestSkipped("LoremPixel is offline, skipping image download");
        }

        
$file Image::image(sys_get_temp_dir());
        
$this->assertFileExists($file);
        if (
function_exists('getimagesize')) {
            list(
$width$height$type$attr) = getimagesize($file);
            
$this->assertEquals(640$width);
            
$this->assertEquals(480$height);
            
$this->assertEquals(constant('IMAGETYPE_JPEG'), $type);
        } else {
            
$this->assertEquals('jpg'pathinfo($filePATHINFO_EXTENSION));
        }
        if (
file_exists($file)) {
            
unlink($file);
        }
    }
}
Онлайн: 1
Реклама