Skip to content

Commit ac361a6

Browse files
committed
OData serializer adjustments, unit tests fixes
1 parent 0f4f36b commit ac361a6

4 files changed

Lines changed: 28 additions & 3 deletions

File tree

src/OneNote/Onenote.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88

99
use Office365\Entity;
10+
use Office365\EntityCollection;
1011
use Office365\OneNote\Pages\OnenotePageCollection;
12+
use Office365\OneNote\Sections\OnenoteSection;
1113
use Office365\Runtime\ResourcePath;
1214
/**
1315
* "The entry point for OneNote resources."
@@ -23,4 +25,15 @@ public function getPages()
2325
return $this->getProperty("Pages",
2426
new OnenotePageCollection($this->getContext(),new ResourcePath("Pages", $this->getResourcePath())));
2527
}
28+
29+
/**
30+
* @return EntityCollection
31+
*/
32+
public function getSections()
33+
{
34+
return $this->getProperty("Sections",
35+
new EntityCollection($this->getContext(),
36+
new ResourcePath("Sections",
37+
$this->getResourcePath()), OnenoteSection::class));
38+
}
2639
}

src/Runtime/OData/ODataRequest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private function nextProperty($json, $format)
263263
yield "value" => $json;
264264

265265

266-
if (isset($json[$format->CollectionTag])) {
266+
if (isset($json[$format->CollectionTag]) && is_array($json[$format->CollectionTag])) {
267267
if (isset($json[$format->NextCollectionTag])) {
268268
yield $format->NextCollectionTag => $json[$format->NextCollectionTag];
269269
}
@@ -312,7 +312,8 @@ private function isValidProperty($key,$value,$format)
312312
} else if ($format instanceof JsonFormat) {
313313
return fnmatch("$format->ControlFamilyTag.*", $key) !== true
314314
&& fnmatch("*$format->ControlFamilyTag.*", $key) !== true
315-
&& fnmatch("$format->TypeTag.*", $key) !== true;
315+
&& fnmatch("$format->TypeTag.*", $key) !== true
316+
&& fnmatch("#microsoft.graph.*", $key) !== true;
316317

317318
}
318319
return true;

tests/onenote/OneNoteTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ class OneNoteTest extends GraphTestCase
77
{
88

99
public function testListPages(){
10-
$pages = self::$graphClient->getMe()->getOnenote()->getPages()->top(10)->get()->executeQuery();
10+
$sections = self::$graphClient->getMe()->getOnenote()->getSections()->top(1)->get()->executeQuery();
11+
self::assertGreaterThan(0, $sections->getCount());
12+
$pages = $sections[0]->getPages()->top(10)->get()->executeQuery();
1113
self::assertNotNull($pages->getServerObjectIsNull());
1214
}
1315

tests/teams/TeamsTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
class TeamsTest extends GraphTestCase
1212
{
1313

14+
/**
15+
* @var Team
16+
*/
17+
protected static $targetTeam;
18+
1419
public function testGetJoinedTeams()
1520
{
1621
$myTeams = self::$graphClient->getMe()->getJoinedTeams()->get()->executeQuery();
@@ -70,6 +75,7 @@ public function testAddTeamMember(Team $team)
7075
$user = self::$graphClient->getUsers()->getById(self::$testAccountName);
7176
$member = $team->addMember($user, ["owner"])->executeQuery();
7277
self::assertNotNull($member->getResourcePath());
78+
self::$targetTeam = $team;
7379
return $member;
7480
}
7581

@@ -91,7 +97,10 @@ public function testListTeamMembers(Team $team)
9197
*/
9298
public function testRemoveTeamMember(Entity $member)
9399
{
100+
$membersBefore = self::$targetTeam->getMembers()->get()->executeQuery();
94101
$member->deleteObject()->executeQuery();
102+
$membersAfter = self::$targetTeam->getMembers()->get()->executeQuery();
103+
self::assertEquals($membersBefore->getCount() - 1, $membersAfter->getCount());
95104
}
96105

97106
/**

0 commit comments

Comments
 (0)