1<?php 2 3namespace Sabre\DAV; 4 5class SyncTokenPropertyTest extends \Sabre\DAVServerTest { 6 7 /** 8 * The assumption in these tests is that a PROPFIND is going on, and to 9 * fetch the sync-token, the event handler is just able to use the existing 10 * result. 11 * 12 * @dataProvider data 13 */ 14 function testAlreadyThere1($name, $value) { 15 16 $propFind = new PropFind('foo', [ 17 '{http://calendarserver.org/ns/}getctag', 18 $name, 19 ]); 20 21 $propFind->set($name, $value); 22 $corePlugin = new CorePlugin(); 23 $corePlugin->propFindLate($propFind, new SimpleCollection('hi')); 24 25 $this->assertEquals("hello", $propFind->get('{http://calendarserver.org/ns/}getctag')); 26 27 } 28 29 /** 30 * In these test-cases, the plugin is forced to do a local propfind to 31 * fetch the items. 32 * 33 * @dataProvider data 34 */ 35 function testRefetch($name, $value) { 36 37 $this->server->tree = new Tree( 38 new SimpleCollection('root', [ 39 new Mock\PropertiesCollection( 40 'foo', 41 [], 42 [$name => $value] 43 ) 44 ]) 45 ); 46 $propFind = new PropFind('foo', [ 47 '{http://calendarserver.org/ns/}getctag', 48 $name, 49 ]); 50 51 $corePlugin = $this->server->getPlugin('core'); 52 $corePlugin->propFindLate($propFind, new SimpleCollection('hi')); 53 54 $this->assertEquals("hello", $propFind->get('{http://calendarserver.org/ns/}getctag')); 55 56 } 57 58 function testNoData() { 59 60 $this->server->tree = new Tree( 61 new SimpleCollection('root', [ 62 new Mock\PropertiesCollection( 63 'foo', 64 [], 65 [] 66 ) 67 ]) 68 ); 69 70 $propFind = new PropFind('foo', [ 71 '{http://calendarserver.org/ns/}getctag', 72 ]); 73 74 $corePlugin = $this->server->getPlugin('core'); 75 $corePlugin->propFindLate($propFind, new SimpleCollection('hi')); 76 77 $this->assertNull($propFind->get('{http://calendarserver.org/ns/}getctag')); 78 79 } 80 81 function data() { 82 83 return [ 84 [ 85 '{http://sabredav.org/ns}sync-token', 86 "hello" 87 ], 88 [ 89 '{DAV:}sync-token', 90 "hello" 91 ], 92 [ 93 '{DAV:}sync-token', 94 new Xml\Property\Href(Sync\Plugin::SYNCTOKEN_PREFIX . "hello", false) 95 ] 96 ]; 97 98 } 99 100} 101