<commit_before><?php

namespace duncan3dc\SonosTests;

use duncan3dc\Sonos\Tracks\Track;

class PlaylistLiveTest extends LiveTest
{
    protected $playlist;
    protected $playlistName = "phpunit-test";

    public function setUp()
    {
        parent::setUp();

        if ($this->network->hasPlaylist($this->playlistName)) {
            $this->playlist = $this->network->getPlaylistByName($this->playlistName);
        } else {
            $this->playlist = $this->network->createPlaylist($this->playlistName);
        }
    }


    public function tearDown()
    {
        if ($this->playlist) {
            $this->playlist->delete();
        }
    }


    public function testGetName()
    {
        $this->assertSame($this->playlistName, $this->playlist->getName());
    }


    public function testAddTrack()
    {
        $uri = "x-file-cifs://TEST/music/artist/album/01-Song.mp3";
        $this->playlist->addTrack($uri);

        $tracks = $this->playlist->getTracks();
<commit_msg>Ensure a playlist created from just an ID can get its name<commit_after><?php

namespace duncan3dc\SonosTests;

use duncan3dc\Sonos\Playlist;
use duncan3dc\Sonos\Tracks\Track;

class PlaylistLiveTest extends LiveTest
{
    protected $playlist;
    protected $playlistName = "phpunit-test";

    public function setUp()
    {
        parent::setUp();

        if ($this->network->hasPlaylist($this->playlistName)) {
            $this->playlist = $this->network->getPlaylistByName($this->playlistName);
        } else {
            $this->playlist = $this->network->createPlaylist($this->playlistName);
        }
    }


    public function tearDown()
    {
        if ($this->playlist) {
            $this->playlist->delete();
        }
    }


    public function testGetName()
    {
        $this->assertSame($this->playlistName, $this->playlist->getName());
    }
    public function testGetNameFromNetwork()
    {
        $id = $this->playlist->getId();
        $playlist = new Playlist($id, $this->network->getController());
        $this->assertSame($this->playlistName, $playlist->getName());
    }


    public function testAddTrack()
    {
        $uri = "x-file-cifs://TEST/music/artist/album/01-Song.mp3";
        $this->playlist->addTrack($uri);

        $tracks = $this->playlist->getTracks();

{'fraction_non_alphanumeric': 0.15317667536988686, 'fraction_numerical': 0.004786771105308964, 'mean_word_length': 2.6261829652996846, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7527732', 'n_tokens_mistral': 737, 'n_tokens_neox': 711, 'n_words': 112}