Skip to content

Commit c1ea857

Browse files
[TASKSCLOUD-249] - Added new tests, changed some other tests due to increase DocumentProperties count.
1 parent d1a98cc commit c1ea857

File tree

5 files changed

+92
-12
lines changed

5 files changed

+92
-12
lines changed

tests/Aspose/Tasks/Calendars/CalendarsTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,21 @@ public function testDeleteNonExistingCalendar()
245245
{
246246
$remoteName = "testDeleteNonExistingCalendar.mpp";
247247
$folder = $this->uploadTestFile("Home move plan.mpp", $remoteName, '');
248-
249-
$response = $this->tasks->deleteCalendar(new Requests\DeleteCalendarRequest($remoteName, 20, self::$storageName, $folder, null));
250-
Assert::assertEquals(404, $response->getCode());
248+
try
249+
{
250+
$this->tasks->deleteCalendar(new Requests\DeleteCalendarRequest($remoteName, 20, self::$storageName, $folder, null));
251+
$catched = false;
252+
}
253+
catch(Aspose\Tasks\ApiException $e)
254+
{
255+
Assert::assertEquals(404, $e->getCode());
256+
$errorObject = json_decode($e->getResponseBody(), true);
257+
Assert::assertEquals("NonexistentCalendar", $errorObject["Error"]["Code"]);
258+
Assert::assertEquals("Specified calendar does not exist", $errorObject["Error"]["Message"]);
259+
$catched = true;
260+
}
261+
262+
Assert::assertTrue($catched, "Expected ApiException is not thrown");
251263
}
252264

253265
public function testDeleteCalendarByUid()

tests/Aspose/Tasks/DocumentProperties/DocumentPropertiesTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testGetDocumentProperties()
4141
$response = $this->tasks->getDocumentProperties(new Requests\GetDocumentPropertiesRequest($remoteName, self::$storageName, $folder));
4242

4343
Assert::assertEquals(200, $response->getCode());
44-
Assert::assertEquals(49, count($response->getProperties()->getList()));
44+
Assert::assertEquals(51, count($response->getProperties()->getList()));
4545
Assert::assertEquals("Title", $response->getProperties()->getList()[0]->getName());
4646
Assert::assertEquals("Home Move", $response->getProperties()->getList()[0]->getValue());
4747
}
@@ -73,7 +73,7 @@ public function testEditDocumentProperty()
7373

7474
$response = $this->tasks->getDocumentProperties(new Requests\GetDocumentPropertiesRequest($remoteName, self::$storageName, $folder));
7575
Assert::assertEquals(200, $response->getCode());
76-
Assert::assertEquals(49, count($response->getProperties()->getList()));
76+
Assert::assertEquals(51, count($response->getProperties()->getList()));
7777

7878
foreach($response->getProperties()->getList() as $p)
7979
{
@@ -102,7 +102,7 @@ public function testEditDocumentPropertyViaPost()
102102

103103
$response = $this->tasks->getDocumentProperties(new Requests\GetDocumentPropertiesRequest($remoteName, self::$storageName, $folder));
104104
Assert::assertEquals(200, $response->getCode());
105-
Assert::assertEquals(49, count($response->getProperties()->getList()));
105+
Assert::assertEquals(51, count($response->getProperties()->getList()));
106106

107107
foreach($response->getProperties()->getList() as $p)
108108
{
@@ -131,7 +131,7 @@ public function testAddNonExistingDocumentProperty()
131131

132132
$response = $this->tasks->getDocumentProperties(new Requests\GetDocumentPropertiesRequest($remoteName, self::$storageName, $folder));
133133
Assert::assertEquals(200, $response->getCode());
134-
Assert::assertEquals(49, count($response->getProperties()->getList()));
134+
Assert::assertEquals(51, count($response->getProperties()->getList()));
135135

136136
foreach($response->getProperties()->getList() as $p)
137137
{

tests/Aspose/Tasks/Project/ImportProjectTest.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,44 @@ public function testImportFromMspDatabase()
5454
Assert::assertEquals(1, count($response->getProjectIds()));
5555
Assert::assertEquals("0", $response->getProjectIds()[0]);
5656
}
57-
58-
57+
58+
5959
public function testImportFromPrimaveraFile()
6060
{
6161
$remoteName = "testImportFromPrimaveraFile.xml";
6262
$folder = $this->uploadTestFile("p6_multiproject.xml", $remoteName, '');
63-
63+
6464
$response = $this->tasks->putImportProjectFromFile(new Requests\PutImportProjectFromFileRequest($remoteName,
6565
"111",
6666
"imported_from_primavera.xml",
6767
Model\ImportedProjectType::PRIMAVERA_XML,
6868
$folder,
6969
Model\ProjectFileFormat::P6XML));
70-
70+
7171
Assert::assertEquals(200, $response->getCode());
72-
72+
7373
$response = $this->tasks->getTasks(new Requests\GetTasksRequest("imported_from_primavera.xml", self::$storageName, $folder));
7474
Assert::assertEquals(200, $response->getCode());
7575
Assert::assertEquals(12, count($response->getTasks()->getTaskItem()));
7676
}
77+
78+
79+
public function testImportFromProjectOnline()
80+
{
81+
static::markTestSkipped('Ignored because real credentials for project server online is required');
82+
83+
$remoteName = "testImportFromProjectOnline.pdf";
84+
85+
$response = $this->tasks->putImportFromProjectOnline(new Requests\PutImportFromProjectOnlineRequest($remoteName,
86+
"https://your_company_name.sharepoint.com",
87+
"262e5ead-1048-4a26-b558-c5eab06bcc5b",
88+
"SOMESECRETTOKEN",
89+
Model\ProjectFileFormat::PDF));
90+
91+
Assert::assertEquals(200, $response->getCode());
92+
93+
$response = $this->tasks->downloadFile($remoteName);
94+
95+
Assert::assertNotNull($response);
96+
}
7797
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/*
3+
* --------------------------------------------------------------------------------------------------------------------
4+
* <copyright company="Aspose" file="ProjectListTest.php">
5+
* Copyright (c) 2019 Aspose.Tasks Cloud
6+
* </copyright>
7+
* <summary>
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all
16+
* copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
* SOFTWARE.
25+
* </summary>
26+
* --------------------------------------------------------------------------------------------------------------------
27+
*/
28+
29+
include_once(realpath(dirname(__FILE__) . '/..') . "/BaseTestContext.php");
30+
use PHPUnit\Framework\Assert;
31+
use Aspose\Tasks\Model\Requests;
32+
use Aspose\Tasks\Model;
33+
use Aspose\Tasks\Model\Requests\GetProjectListRequest;
34+
35+
class ProjectListTest extends BaseTestContext
36+
{
37+
public function testGetProjectList()
38+
{
39+
static::markTestSkipped('Ignored because real credentials for project server online is required');
40+
41+
$response = $this->tasks->getProjectList(new GetProjectListRequest
42+
('https://your_company_name.sharepoint.com', 'SOMESECRETTOKEN'));
43+
44+
Assert::assertEquals(200, $response->getCode());
45+
Assert::assertNotEmpty($response->getProjects());
46+
}
47+
}

tests/Aspose/Tasks/TasksApiTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function testApiCoverage()
4848
'Project\ImportProjectTest',
4949
'Project\GetPageCountTest',
5050
'Project\TaskDocumentFormatTest',
51+
'ProjectOnline\ProjectListTest',
5152
'Recalculation\RecalculationTest',
5253
'Reports\ReportTest',
5354
'Resources\ResourcesTest',

0 commit comments

Comments
 (0)