<commit_before><?php
namespace Imagelint\Tests;

use Imagelint\Imagelint;
use PHPUnit\Framework\TestCase;

/**
 * @covers \Imagelint\Imagelint
 */
class ImagelintTest extends TestCase
{
    public function testHttpURL()
    {
        $this->assertEquals(Imagelint::get('http://example.com/foo/image.jpg'), 'https://a1.imagelint.com/example.com/foo/image.jpg');
    }

    public function testHttpsURL() {
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg'),'https://a1.imagelint.com/example.com/foo/image.jpg');
    }

    public function testFragmentURL() {
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg#xyz'),'https://a1.imagelint.com/example.com/foo/image.jpg');
    }

    public function testParameterURL() {
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg', ['width'=>200]),'https://a1.imagelint.com/example.com/foo/image.jpg?il-width=200');
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg', ['width'=>200,'height'=>200]),'https://a1.imagelint.com/example.com/foo/image.jpg?il-width=200&il-height=200');
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg', ['width'=>200,'height'=>200,'dpr'=>2]),'https://a1.imagelint.com/example.com/foo/image.jpg?il-width=200&il-height=200&il-dpr=2');
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg?a=1', ['width'=>200,'height'=>200,'dpr'=>2]),'https://a1.imagelint.com/example.com/foo/image.jpg?a=1&il-width=200&il-height=200&il-dpr=2');
    }

    public function testAuthURL() {
        $this->assertEquals(Imagelint::get('https://user:password@example.com/foo/image.jpg'),'https://a1.imagelint.com/user:password@example.com/foo/image.jpg');
    }
    
    public function testInvalidURL() {
        $this->expectException(\InvalidArgumentException::class);
        Imagelint::get('ftp://example.com/foo/image.jpg');
    }

    public function testInvalidURLWithoutProtocol() {
        $this->expectException(\InvalidArgumentException::class);
        $this->assertEquals(Imagelint::get('example.com/foo/image.jpg'),'https://a1.imagelint.com/example.com/foo/image.jpg');
    }
}
<commit_msg>Fix phpunit for php <= 5.5<commit_after><?php
namespace Imagelint\Tests;

use Imagelint\Imagelint;
use PHPUnit\Framework\TestCase;

/**
 * @covers \Imagelint\Imagelint
 */
class ImagelintTest extends TestCase
{
    public function testHttpURL()
    {
        $this->assertEquals(Imagelint::get('http://example.com/foo/image.jpg'), 'https://a1.imagelint.com/example.com/foo/image.jpg');
    }

    public function testHttpsURL() {
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg'),'https://a1.imagelint.com/example.com/foo/image.jpg');
    }

    public function testFragmentURL() {
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg#xyz'),'https://a1.imagelint.com/example.com/foo/image.jpg');
    }

    public function testParameterURL() {
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg', ['width'=>200]),'https://a1.imagelint.com/example.com/foo/image.jpg?il-width=200');
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg', ['width'=>200,'height'=>200]),'https://a1.imagelint.com/example.com/foo/image.jpg?il-width=200&il-height=200');
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg', ['width'=>200,'height'=>200,'dpr'=>2]),'https://a1.imagelint.com/example.com/foo/image.jpg?il-width=200&il-height=200&il-dpr=2');
        $this->assertEquals(Imagelint::get('https://example.com/foo/image.jpg?a=1', ['width'=>200,'height'=>200,'dpr'=>2]),'https://a1.imagelint.com/example.com/foo/image.jpg?a=1&il-width=200&il-height=200&il-dpr=2');
    }

    public function testAuthURL() {
        $this->assertEquals(Imagelint::get('https://user:password@example.com/foo/image.jpg'),'https://a1.imagelint.com/user:password@example.com/foo/image.jpg');
    }
    
    public function testInvalidURL() {
        if(method_exists($this, 'setExpectedException')) {
            $this->setExpectedException(\InvalidArgumentException::class);
        } else {
            $this->expectException(\InvalidArgumentException::class);
        }
        Imagelint::get('ftp://example.com/foo/image.jpg');
    }

    public function testInvalidURLWithoutProtocol() {
        if(method_exists($this,'setExpectedException')) {
            $this->setExpectedException(\InvalidArgumentException::class);
        } else {
            $this->expectException(\InvalidArgumentException::class);
        }
        $this->assertEquals(Imagelint::get('example.com/foo/image.jpg'),'https://a1.imagelint.com/example.com/foo/image.jpg');
    }
}

{'fraction_non_alphanumeric': 0.20113255033557048, 'fraction_numerical': 0.024328859060402684, 'mean_word_length': 4.161255411255412, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 45, 'https://': 32, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1170400', 'n_tokens_mistral': 1683, 'n_tokens_neox': 1605, 'n_words': 113}