1
0
mirror of https://github.com/chylex/Nextcloud-News.git synced 2024-11-24 22:42:46 +01:00
Nextcloud-News/tests/Unit/Db/FolderTest.php
Paul Tirk 1208dc8d71 add tests for 'toAPI2' method
Signed-off-by: Paul Tirk <paultirk@paultirk.com>
2021-04-08 10:23:11 +02:00

106 lines
2.5 KiB
PHP

<?php
/**
* Nextcloud - News
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Alessandro Cosentino <cosenal@gmail.com>
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright 2012 Alessandro Cosentino
* @copyright 2012-2014 Bernhard Posselt
*/
namespace OCA\News\Tests\Unit\Db;
use OCA\News\Db\Folder;
use PHPUnit\Framework\TestCase;
class FolderTest extends TestCase
{
public function testToAPI()
{
$folder = new Folder();
$folder->setId(3);
$folder->setName('name');
$folder->setOpened(false);
$this->assertEquals(
[
'id' => 3,
'name' => 'name',
'opened' => false,
'feeds' => [],
], $folder->toAPI()
);
}
public function testToAPI2()
{
$folder = new Folder();
$folder->setId(3);
$folder->setName('name');
$folder->setOpened(false);
$this->assertEquals(
[
'id' => 3,
'name' => 'name',
'opened' => false,
'feeds' => []
],
$folder->toAPI2()
);
}
public function testSerialize()
{
$folder = new Folder();
$folder->setId(3);
$folder->setName('john');
$folder->setParentId(4);
$folder->setUserId('abc');
$folder->setOpened(true);
$folder->setDeletedAt(9);
$this->assertEquals(
[
'id' => 3,
'parentId' => 4,
'name' => 'john',
'userId' => 'abc',
'opened' => true,
'deletedAt' => 9,
], $folder->jsonSerialize()
);
}
public function testSetDeletedAt()
{
$folder = new Folder();
$folder->setDeletedAt(15);
$this->assertEquals(15, $folder->getDeletedAt());
}
public function testSetLastModified()
{
$folder = new Folder();
$folder->setLastModified('15');
$this->assertEquals('15', $folder->getLastModified());
}
public function testSetParentId()
{
$folder = new Folder();
$folder->setParentId(15);
$this->assertEquals(15, $folder->getParentId());
}
public function testSetUserId()
{
$folder = new Folder();
$folder->setUserId('15');
$this->assertEquals('15', $folder->getUserId());
}
}