public function test_delete_playlist_item_returns_results() { $mock = new MockHandler([new Response(200, [], file_get_contents('tests/json/playlist_item_delete_success.json'))]); $container = []; $history = Middleware::history($container); $handler = HandlerStack::create($mock); $handler->push($history); $client = new Client(['handler' => $handler]); $api = new Qlite(['client' => $client]); $response = $api->deletePlaylistItem('apikey', 16, 103, 705); foreach ($container as $transaction) { $this->assertEquals('DELETE', $transaction['request']->getMethod()); } $this->assertEquals(705, $response->getId()); }
public function test_login_is_successful() { $mock = new MockHandler([new Response(200, [], file_get_contents('tests/json/login_success.json'))]); $container = []; $history = Middleware::history($container); $handler = HandlerStack::create($mock); $handler->push($history); $client = new Client(['handler' => $handler]); $api = new Qlite(['client' => $client]); $response = $api->login('username', 'password'); foreach ($container as $transaction) { $this->assertEquals('POST', $transaction['request']->getMethod()); } $this->assertTrue($response->isAuthenticated()); $this->assertEquals('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6InRlc3RfaWQifQ.eyJpc3MiOiJodHRwczpcL1wvZGV2Mi1jbG91ZC5xLWxpdGUuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2RldjItY2xvdWQucS1saXRlLmNvbSIsImp0aSI6InRlc3RfaWQiLCJpYXQiOjE0NjkwMTk0ODEsIm5iZiI6MTQ2OTAxOTQ4MSwiZXhwIjoxNDY5MDIxMjgxLCJ1c2VyIjp7ImlkIjoiOTY0IiwidXNlcm5hbWUiOiJhZHN1cF9hZG1pbiIsInByb2plY3RpZCI6IjkiLCJkZWZhdWx0cHJvamVjdGlkIjoiOSIsImRlZmF1bHRwYWdlIjpudWxsLCJwciI6W3siaWQiOiI5Iiwic2MiOltbMSwxLDEsMCwxXSxbMSwxLDEsMCwxXSxbMSwxLDAsMCwxXSxbMSwxLDEsMCwxXSxbMSwxLDEsMCwxXSxbMCwwLDAsMCwxXSxbMCwwLDAsMCwxXV0sInByIjpbeyJpZCI6IjEwIiwic2MiOltbMSwxLDEsMCwxXSxbMSwxLDEsMCwxXSxbMSwxLDAsMCwxXSxbMSwxLDEsMCwxXSxbMSwxLDEsMCwxXSxbMCwwLDAsMCwxXSxbMCwwLDAsMCwxXV19XX1dfX0.2Gj9BO9drfuPYoNAGLuwb8Cg12IgqKbXktDfTmJ1QM4', $response->getApiKey()); }
public function test_create_library_item_returns_results() { $mock = new MockHandler([new Response(200, [], file_get_contents('tests/json/library_item_create_success.json'))]); $container = []; $history = Middleware::history($container); $handler = HandlerStack::create($mock); $handler->push($history); $client = new Client(['handler' => $handler]); $api = new Qlite(['client' => $client]); $response = $api->createLibraryItem('apikey', 10, 62, 'Test Item Name', 'tests/image/example.jpg', 'tag tag2'); foreach ($container as $transaction) { $this->assertEquals('POST', $transaction['request']->getMethod()); } $this->assertEquals(352, $response->getId()); $this->assertEquals('Test Item Name', $response->getName()); }
public function test_update_playlist_returns_results() { $mock = new MockHandler([new Response(200, [], file_get_contents('tests/json/playlist_update_success.json'))]); $container = []; $history = Middleware::history($container); $handler = HandlerStack::create($mock); $handler->push($history); $client = new Client(['handler' => $handler]); $api = new Qlite(['client' => $client]); $response = $api->updatePlaylist('apikey', 10, 101, ['autopublish' => true]); foreach ($container as $transaction) { $this->assertEquals('PUT', $transaction['request']->getMethod()); } $this->assertEquals(101, $response->getId()); $this->assertEquals(10, $response->getProjectId()); $this->assertEquals('Test Playlist Name', $response->getName()); }
public function test_get_project_with_sub_projects_returns_results() { return; // Add this later $mock = new MockHandler([new Response(200, [], file_get_contents('tests/json/project_success.json'))]); $container = []; $history = Middleware::history($container); $handler = HandlerStack::create($mock); $handler->push($history); $client = new Client(['handler' => $handler]); $api = new Qlite(['client' => $client]); $response = $api->getProject('apikey', 9); foreach ($container as $transaction) { $this->assertEquals('GET', $transaction['request']->getMethod()); } $this->assertEquals(9, $response->getId()); $this->assertEquals('Project Name', $response->getName()); $this->assertEquals(1, count($response->getProjects())); $childProjects = $response->getProjects(); $childProject = array_shift($childProjects); $this->assertEquals(10, $childProject->getId()); $this->assertEquals('Displays 216x384', $childProject->getName()); }