apiRequest( 'http://wishthis.online.localhost/api/wishes', \CURLOPT_POST, [ 'wish_title' => 'WD Red SA500 NAS SATA SSD 2TB 2.5": Amazon.de: Computer & Accessories', 'wishlist_id' => $this->testWishlistId, ] ); $this->assertNotFalse($apiResponse); $json = \json_decode($apiResponse, true); $this->assertNotNull($json); $this->assertTrue($json['success']); $this->assertEmpty($json['warning'], 'There has been unexpected output.'); } public function testTitleOver128Chars(): void { $apiResponse = $this->apiRequest( 'http://wishthis.online.localhost/api/wishes', \CURLOPT_POST, [ 'wish_title' => '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', 'wishlist_id' => $this->testWishlistId, ] ); $this->assertNotFalse($apiResponse); $json = \json_decode($apiResponse, true); $this->assertNotNull($json); $this->assertTrue($json['success']); $this->assertEmpty($json['warning'], 'There has been unexpected output.'); } /** * Move this into a different testing class * * @return void */ // public function testTitleWithSpecialCharacters(): void // { // $expectedTitle = '!"§$%&/()=?´öäü+#,.-*\'_:;~´`^âàûúôò'; // // $apiResponse = $this->apiRequest( // 'http://wishthis.online.localhost/api/wishes', // \CURLOPT_POST, // array( // 'wish_title' => $expectedTitle, // 'wishlist_id' => $this->testWishlistId, // ) // ); // $this->assertNotFalse($apiResponse); // // $json = \json_decode($apiResponse, true); // $this->assertNotNull($json); // $this->assertTrue($json['success']); // $this->assertEmpty($json['warning'], 'There has been unexpected output.'); // } public function testDescriptionOnly(): void { $apiResponse = $this->apiRequest( 'http://wishthis.online.localhost/api/wishes', \CURLOPT_POST, [ 'wish_description' => 'WD Red SA500 NAS SATA SSD 2TB 2.5": Amazon.de: Computer & Accessories', 'wishlist_id' => $this->testWishlistId, ] ); $this->assertNotFalse($apiResponse); $json = \json_decode($apiResponse, true); $this->assertNotNull($json); $this->assertTrue($json['success']); $this->assertEmpty($json['warning'], 'There has been unexpected output.'); } public function testUrlOnly(): void { $apiResponse = $this->apiRequest( 'http://wishthis.online.localhost/api/wishes', \CURLOPT_POST, [ 'wish_url' => 'https://www.amazon.com/Red-SA500-NAS-NAND-Internal/dp/B07YFGG261', 'wishlist_id' => $this->testWishlistId, ] ); $this->assertNotFalse($apiResponse); $json = \json_decode($apiResponse, true); $this->assertNotNull($json); $this->assertTrue($json['success']); $this->assertEmpty($json['warning'], 'There has been unexpected output.'); } public function testUrlOver255Chars(): void { $apiResponse = $this->apiRequest( 'http://wishthis.online.localhost/api/wishes', \CURLOPT_POST, [ 'wish_url' => 'https://www.amazon.com/Red-SA500-NAS-NAND-Internal/dp/B07YFGG261?012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', 'wishlist_id' => $this->testWishlistId, ] ); $this->assertNotFalse($apiResponse); $json = \json_decode($apiResponse, true); $this->assertNotNull($json); $this->assertTrue($json['success']); $this->assertEmpty($json['warning'], 'There has been unexpected output.'); } }