<commit_before><?php

require 'Wallhaven.php';

class WallhavenTest extends PHPUnit_Framework_TestCase
{
    public function testCredentialsNotNull()
    {
        $this->assertNotEmpty(getenv('WALLHAVENUSERNAME'));
        $this->assertNotEmpty(getenv('WALLHAVENPASSWORD'));
    }

    public function testLogin()
    {
        new Wallhaven(getenv('WALLHAVENUSERNAME'), getenv('WALLHAVENPASSWORD'));
    }

    /**
     * @expectedException Exception
     */
    public function testLoginFail()
    {
        new Wallhaven("this user should not exist", "wrong password");
    }

    public function testSearchSafeLoggedOut()
    {
        $wh = new Wallhaven();

        $result = $wh->search("macro", WH_CATEGORY_GENERAL, WH_PURITY_SAFE, "relevance", "desc", [], [], false);

        $this->assertNotEmpty($result);
    }

    public function testSearchSafeLoggedIn()
    {
        $wh = new Wallhaven(getenv('WALLHAVENUSERNAME'), getenv('WALLHAVENPASSWORD'));

        $result = $wh->search("macro", WH_CATEGORY_GENERAL, WH_PURITY_SAFE, "relevance", "desc", [], [], false);

        $this->assertNotEmpty($result);
    }

    public function testSearchNsfwLoggedOut()
    {
        $wh = new Wallhaven();

        $result = $wh->getRandom(WH_CATEGORY_GENERAL, WH_PURITY_NSFW);

        $this->assertEmpty($result);
    }

    public function testSearchNsfwLoggedIn()
    {
        $wh = new Wallhaven(getenv('WALLHAVENUSERNAME'), getenv('WALLHAVENPASSWORD'));

        $result = $wh->search(null, WH_CATEGORY_GENERAL, WH_PURITY_NSFW, "random", "desc", [], [], false);

        $this->assertNotEmpty($result);
    }

    public function testWallpaperInformation()
    {
        $wh = new Wallhaven();
        $wh->getWallpaperInformation(109965);
    }

    /**
     * @expectedException Exception
     * @expectedExceptionMessage HTTP Error 404
     */
    public function testNonExistentWallpaperInformation()
    {
        $wh = new Wallhaven();
        $wh->getWallpaperInformation(300000000);
    }

    /**
     * @expectedException Exception
     * @expectedExceptionMessage HTTP Error 403
     */
    public function testNsfwWallpaperInformationLoggedOut()
    {
        $wh = new Wallhaven();
        $wh->getWallpaperInformation(2480);
    }

    public function testNsfwWallpaperInformationLoggedIn()
    {
        $wh = new Wallhaven(getenv('WALLHAVENUSERNAME'), getenv('WALLHAVENPASSWORD'));
        $wh->getWallpaperInformation(2480);
    }
}
 <commit_msg>Update failing tests<commit_after><?php

require 'Wallhaven.php';

class WallhavenTest extends PHPUnit_Framework_TestCase
{
    public function testCredentialsNotNull()
    {
        $this->assertNotEmpty(getenv('WALLHAVENUSERNAME'));
        $this->assertNotEmpty(getenv('WALLHAVENPASSWORD'));
    }

    public function testLogin()
    {
        new Wallhaven(getenv('WALLHAVENUSERNAME'), getenv('WALLHAVENPASSWORD'));
    }

    /**
     * @expectedException Exception
     */
    public function testLoginFail()
    {
        new Wallhaven("this user should not exist", "wrong password");
    }

    public function testSearchSafeLoggedOut()
    {
        $wh = new Wallhaven();

        $result = $wh->search("macro", WH_CATEGORY_GENERAL, WH_PURITY_SAFE, "relevance", "desc", [], [], false);

        $this->assertNotEmpty($result);
    }

    public function testSearchSafeLoggedIn()
    {
        $wh = new Wallhaven(getenv('WALLHAVENUSERNAME'), getenv('WALLHAVENPASSWORD'));

        $result = $wh->search("macro", WH_CATEGORY_GENERAL, WH_PURITY_SAFE, "relevance", "desc", [], [], false);

        $this->assertNotEmpty($result);
    }

    public function testSearchNsfwLoggedOut()
    {
        $wh = new Wallhaven();

        $result = $wh->getRandom(WH_CATEGORY_GENERAL, WH_PURITY_NSFW);

        $this->assertEmpty($result);
    }

    public function testSearchNsfwLoggedIn()
    {
        $wh = new Wallhaven(getenv('WALLHAVENUSERNAME'), getenv('WALLHAVENPASSWORD'));

        $result = $wh->search(null, WH_CATEGORY_GENERAL, WH_PURITY_NSFW, "random", "desc", [], [], false);

        $this->assertNotEmpty($result);
    }

    public function testWallpaperInformation()
    {
        $wh = new Wallhaven();
        $wh->getWallpaperInformation(109965);
    }

    /**
     * @expectedException Exception
     * @expectedExceptionMessage HTTP Error 404
     */
    public function testNonExistentWallpaperInformation()
    {
        $wh = new Wallhaven();
        $wh->getWallpaperInformation(300000000);
    }

    /**
     * @expectedException Exception
     * @expectedExceptionMessage HTTP Error 403
     */
    public function testNsfwWallpaperInformationLoggedOut()
    {
        $wh = new Wallhaven();
        $wh->getWallpaperInformation(8273);
    }

    public function testNsfwWallpaperInformationLoggedIn()
    {
        $wh = new Wallhaven(getenv('WALLHAVENUSERNAME'), getenv('WALLHAVENPASSWORD'));
        $wh->getWallpaperInformation(8273);
    }
}
 
{'fraction_non_alphanumeric': 0.12961841308298, 'fraction_numerical': 0.011710074702200686, 'mean_word_length': 3.1386800334168754, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '3552212', 'n_tokens_mistral': 1626, 'n_tokens_neox': 1518, 'n_words': 254}