public function testGetAddedOrDeletedModelsFromReadSubscriptionTable()
 {
     ReadPermissionsSubscriptionUtil::buildTables();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $messageLogger = new DebuggingMessageLogger();
     $task = TaskTestHelper::createTaskByNameForOwner('Test Task', $super);
     // Because ReadPermissionsSubscriptionUtil::updateAllReadSubscriptionTables completed in previous test
     // status need to be ReadPermissionsSubscriptionUtil::STATUS_COMPLETED
     $this->assertEquals(ReadPermissionsSubscriptionUtil::STATUS_COMPLETED, ReadPermissionsSubscriptionUtil::getReadPermissionUpdateStatus());
     $this->assertTrue(ReadPermissionsSubscriptionUtil::isReadPermissionSubscriptionUpdateCompleted());
     ReadPermissionsSubscriptionUtil::updateAllReadSubscriptionTables($messageLogger);
     $this->assertEquals(ReadPermissionsSubscriptionUtil::STATUS_COMPLETED, ReadPermissionsSubscriptionUtil::getReadPermissionUpdateStatus());
     $this->assertTrue(ReadPermissionsSubscriptionUtil::isReadPermissionSubscriptionUpdateCompleted());
     $sql = "SELECT * FROM task_read_subscription WHERE userid = " . $super->id;
     $permissionTableRows = ZurmoRedBean::getAll($sql);
     $this->assertEquals(1, count($permissionTableRows));
     $addedModelIds = ReadPermissionsSubscriptionUtil::getAddedOrDeletedModelsFromReadSubscriptionTable('TestService', 'Task', 0, ReadPermissionsSubscriptionUtil::TYPE_ADD, $super);
     $this->asserttrue(is_array($addedModelIds));
     $this->assertEquals(1, count($addedModelIds));
     ModelCreationApiSyncUtil::insertItem('TestService', $task->id, 'Task', '2013-05-03 15:16:06');
     $addedModelIds = ReadPermissionsSubscriptionUtil::getAddedOrDeletedModelsFromReadSubscriptionTable('TestService', 'Task', 0, ReadPermissionsSubscriptionUtil::TYPE_ADD, $super);
     $this->asserttrue(is_array($addedModelIds));
     $this->assertEquals(0, count($addedModelIds));
 }
 /**
  * @param string $serviceName
  * @param $serviceName
  * @param $modelClassName
  * @param $pageSize
  * @param $offset
  * @param $timestamp
  * @param null $stateMetadataAdapterClassName
  * @return array
  */
 public static function getDeletedModelIds($serviceName, $modelClassName, $pageSize, $offset, $timestamp, $stateMetadataAdapterClassName = null)
 {
     $modelIds = ReadPermissionsSubscriptionUtil::getAddedOrDeletedModelsFromReadSubscriptionTable($serviceName, $modelClassName, $timestamp, ReadPermissionsSubscriptionUtil::TYPE_DELETE, Yii::app()->user->userModel);
     $modelIds = array_slice($modelIds, $offset, $pageSize);
     return $modelIds;
 }
 public function testGetAddedOrDeletedModelsFromReadSubscriptionTable()
 {
     ReadPermissionsSubscriptionUtil::buildTables();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $task = TaskTestHelper::createTaskByNameForOwner('Test Task', $super);
     ReadPermissionsSubscriptionUtil::updateAllReadSubscriptionTables(false);
     $sql = "SELECT * FROM task_read_subscription WHERE userid = " . $super->id;
     $permissionTableRows = R::getAll($sql);
     $this->assertEquals(1, count($permissionTableRows));
     $addedModelIds = ReadPermissionsSubscriptionUtil::getAddedOrDeletedModelsFromReadSubscriptionTable('TestService', 'Task', 0, ReadPermissionsSubscriptionUtil::TYPE_ADD, $super);
     $this->asserttrue(is_array($addedModelIds));
     $this->assertEquals(1, count($addedModelIds));
     ModelCreationApiSyncUtil::insertItem('TestService', $task->id, 'Task', '2013-05-03 15:16:06');
     $addedModelIds = ReadPermissionsSubscriptionUtil::getAddedOrDeletedModelsFromReadSubscriptionTable('TestService', 'Task', 0, ReadPermissionsSubscriptionUtil::TYPE_ADD, $super);
     $this->asserttrue(is_array($addedModelIds));
     $this->assertEquals(0, count($addedModelIds));
 }