|
|
@@ -40,6 +40,52 @@ class DolibarrApiServiceTest extends TestCase
|
|
|
$this->assertEquals(['id' => 1], $society);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @see DolibarrApiService::getSociety()
|
|
|
+ */
|
|
|
+ public function testGetSocietyNotExisting(): void {
|
|
|
+ $dolibarrApiService = $this->getMockBuilder(DolibarrApiService::class)
|
|
|
+ ->setConstructorArgs([$this->client])
|
|
|
+ ->setMethodsExcept(['getSociety'])
|
|
|
+ ->getMock();
|
|
|
+
|
|
|
+ $organizationId = 123;
|
|
|
+
|
|
|
+ $dolibarrApiService
|
|
|
+ ->expects(self::once())
|
|
|
+ ->method('getJsonContent')
|
|
|
+ ->with("thirdparties", [ "limit" => "1", "sqlfilters" => "ref_int=" . $organizationId])
|
|
|
+ ->willThrowException(new HttpException(404));
|
|
|
+
|
|
|
+ $society = $dolibarrApiService->getSociety($organizationId);
|
|
|
+
|
|
|
+ $this->assertEquals(null, $society);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @see DolibarrApiService::getSociety()
|
|
|
+ */
|
|
|
+ public function testGetSocietyWithError(): void {
|
|
|
+ $dolibarrApiService = $this->getMockBuilder(DolibarrApiService::class)
|
|
|
+ ->setConstructorArgs([$this->client])
|
|
|
+ ->setMethodsExcept(['getSociety'])
|
|
|
+ ->getMock();
|
|
|
+
|
|
|
+ $organizationId = 123;
|
|
|
+
|
|
|
+ $e = new HttpException(500);
|
|
|
+
|
|
|
+ $dolibarrApiService
|
|
|
+ ->expects(self::once())
|
|
|
+ ->method('getJsonContent')
|
|
|
+ ->with("thirdparties", [ "limit" => "1", "sqlfilters" => "ref_int=" . $organizationId])
|
|
|
+ ->willThrowException($e);
|
|
|
+
|
|
|
+ $this->expectException($e::class);
|
|
|
+
|
|
|
+ $dolibarrApiService->getSociety($organizationId);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @see DolibarrApiService::getActiveContract()
|
|
|
*/
|