<commit_before><?php

/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service_Audioscrobbler
 * @subpackage UnitTests
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id$
 */


/**
 * Test helper
 */
require_once dirname(__FILE__) . '/../../../TestHelper.php';

/**
 * @see Zend_Service_Audioscrobbler
 */
require_once 'Zend/Service/Audioscrobbler.php';


/**
 * @category   Zend
 * @package    Zend_Service_Audioscrobbler
 * @subpackage UnitTests
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Service_Audioscrobbler_ProfileTest extends PHPUnit_Framework_TestCase
{
    public function testConstructValid()
    {
        try {
            $response = new Zend_Service_Audioscrobbler( );
            $this->assertNotNull($response);
            return;
        } catch (Exception $e) {
            $this->fail("Exception $e->message thrown by test");
        }

    }

    public function testGetProfileInfo()
    {
        try {
            $test_response = "HTTP/1.1 200 OK\r\n" .
                            "Content-type: text/xml\r\n" .
                            "\r\n" .
                            '<?xml version="1.0" encoding="UTF-8"?>
                            <profile id="1000002" cluster="2" username="RJ">
                            <url>http://www.last.fm/user/RJ/</url>

                                <realname><NAME></realname>
                                        <mbox_sha1sum>1b374543545e01bc8d555a6a57c637f61f999fdf</mbox_sha1sum>
                                        <registered unixtime="1037793040">Nov 20, 2002</registered>
                                        <age>24</age>
                                        <gender>m</gender>
                                            <country>United Kingdom</country>
                                    <playcount>45043</playcount>
                                        <avatar>http://static.last.fm/avatar/0f4bda3a8e49e714c26ef610e2893454.jpg</avatar>
                            </profile>';
            $as = new Zend_Service_Audioscrobbler(true, $test_response);
            $as->set('user', 'RJ');
            $response = $as->userGetProfileInformation();
            $this->assertNotNull($response);
            return;
        } catch (Exception $e ) {
            $this->fail("Exception: [" . $e->getMessage() . "] thrown by test");
        }

    }

    public function testGetBadProfileInfo()
    {
        $as = new Zend_Service_Audioscrobbler();
        $as->set('user', 'kljadsfjllkj');

        try {
            $response = $as->userGetProfileInformation();
            $this->assertNull($response);

        } catch (Exception $e) {
            return;
        }

        $this->fail('Exception was not thrown when submitting bad user info');
    }

    public function testUserGetTopArtists( )
    {
        try {
            $test_response = "HTTP/1.1 200 OK\r\n" .
                            "Content-type: text/xml\r\n" .
                            "\r\n" .
                            '<?xml version="1.0" encoding="UTF-8"?>
                            <topartists user="RJ">
                            <artist>
                                <name><NAME></name>
                                <mbid>28503ab7-8bf2-4666-a7bd-2644bfc7cb1d</mbid>
                                <playcount>854</playcount>
                                <rank>1</rank>
                                <url>http://www.last.fm/music/Dream+Theater</url>
                                <thumbnail>http://static.last.fm/proposedimages/thumbnail/6/4209/432600.jpg</thumbnail>
                                <image>http://static.last.fm/proposedimages/sidebar/6/4209/432600.jpg</image>
                            </artist><commit_msg>testGetBadProfileInfo(Zend_Service_Audioscrobbler_ProfileTest) is marked as skipped since it blocks Unit tests execution. [ZF-4560] related.<commit_after><?php

/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service_Audioscrobbler
 * @subpackage UnitTests
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id$
 */


/**
 * Test helper
 */
require_once dirname(__FILE__) . '/../../../TestHelper.php';

/**
 * @see Zend_Service_Audioscrobbler
 */
require_once 'Zend/Service/Audioscrobbler.php';


/**
 * @category   Zend
 * @package    Zend_Service_Audioscrobbler
 * @subpackage UnitTests
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Service_Audioscrobbler_ProfileTest extends PHPUnit_Framework_TestCase
{
    public function testConstructValid()
    {
        try {
            $response = new Zend_Service_Audioscrobbler( );
            $this->assertNotNull($response);
            return;
        } catch (Exception $e) {
            $this->fail("Exception $e->message thrown by test");
        }

    }

    public function testGetProfileInfo()
    {
        try {
            $test_response = "HTTP/1.1 200 OK\r\n" .
                            "Content-type: text/xml\r\n" .
                            "\r\n" .
                            '<?xml version="1.0" encoding="UTF-8"?>
                            <profile id="1000002" cluster="2" username="RJ">
                            <url>http://www.last.fm/user/RJ/</url>

                                <realname><NAME></realname>
                                        <mbox_sha1sum>1b374543545e01bc8d555a6a57c637f61f999fdf</mbox_sha1sum>
                                        <registered unixtime="1037793040">Nov 20, 2002</registered>
                                        <age>24</age>
                                        <gender>m</gender>
                                            <country>United Kingdom</country>
                                    <playcount>45043</playcount>
                                        <avatar>http://static.last.fm/avatar/0f4bda3a8e49e714c26ef610e2893454.jpg</avatar>
                            </profile>';
            $as = new Zend_Service_Audioscrobbler(true, $test_response);
            $as->set('user', 'RJ');
            $response = $as->userGetProfileInformation();
            $this->assertNotNull($response);
            return;
        } catch (Exception $e ) {
            $this->fail("Exception: [" . $e->getMessage() . "] thrown by test");
        }

    }

    public function testGetBadProfileInfo()
    {
        $this->markTestSkipped('Skipped . See [ZF-4560]');

        $as = new Zend_Service_Audioscrobbler();
        $as->set('user', 'kljadsfjllkj');

        try {
            $response = $as->userGetProfileInformation();
            $this->assertNull($response);

        } catch (Exception $e) {
            return;
        }

        $this->fail('Exception was not thrown when submitting bad user info');
    }

    public function testUserGetTopArtists( )
    {
        try {
            $test_response = "HTTP/1.1 200 OK\r\n" .
                            "Content-type: text/xml\r\n" .
                            "\r\n" .
                            '<?xml version="1.0" encoding="UTF-8"?>
                            <topartists user="RJ">
                            <artist>
                                <name>Dream Theater</name>
                                <mbid>28503ab7-8bf2-4666-a7bd-2644bfc7cb1d</mbid>
                                <playcount>854</playcount>
                                <rank>1</rank>
                                <url>http://www.last.fm/music/Dream+Theater</url>
                                <thumbnail>http://static.last.fm/proposedimages/thumbnail/6/4209/432600.jpg</thumbnail>
                                <image>http://static.last.fm/proposedimages/sidebar/6/4209/432600.jpg</image>
                            </artist>
{'fraction_non_alphanumeric': 0.11983653633753037, 'fraction_numerical': 0.03578528827037773, 'mean_word_length': 1.5543018335684062, 'pattern_counts': {'":': 0, '<': 88, '<?xml version=': 4, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7583274', 'n_tokens_mistral': 2788, 'n_tokens_neox': 2527, 'n_words': 495}