A free, self-hostable aggregator…
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

230 lines
7.7 KiB

<?php
/**
* Description of UserQueryTest
*/
class UserQueryTest extends PHPUnit\Framework\TestCase {
public function test__construct_whenAllQuery_storesAllParameters() {
$query = array('get' => 'a');
$user_query = new FreshRSS_UserQuery($query);
$this->assertEquals('all', $user_query->getGetName());
$this->assertEquals('all', $user_query->getGetType());
}
public function test__construct_whenFavoriteQuery_storesFavoriteParameters() {
$query = array('get' => 's');
$user_query = new FreshRSS_UserQuery($query);
$this->assertEquals('favorite', $user_query->getGetName());
$this->assertEquals('favorite', $user_query->getGetType());
}
/**
* @expectedException Exceptions/FreshRSS_DAO_Exception
* @expectedExceptionMessage Category DAO is not loaded in UserQuery
*/
public function test__construct_whenCategoryQueryAndNoDao_throwsException() {
$this->markTestIncomplete('There is a problem with the exception autoloading. We need to make a better autoloading process');
$query = array('get' => 'c_1');
new FreshRSS_UserQuery($query);
}
public function test__construct_whenCategoryQuery_storesCategoryParameters() {
$category_name = 'some category name';
$cat = $this->getMock('FreshRSS_Category');
$cat->expects($this->atLeastOnce())
[ci] Add Travis (#1619) * [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
7 years ago
->method('name')
->withAnyParameters()
->willReturn($category_name);
$cat_dao = $this->getMock('FreshRSS_Searchable');
$cat_dao->expects($this->atLeastOnce())
[ci] Add Travis (#1619) * [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
7 years ago
->method('searchById')
->withAnyParameters()
->willReturn($cat);
$query = array('get' => 'c_1');
$user_query = new FreshRSS_UserQuery($query, null, $cat_dao);
$this->assertEquals($category_name, $user_query->getGetName());
$this->assertEquals('category', $user_query->getGetType());
}
/**
* @expectedException Exceptions/FreshRSS_DAO_Exception
* @expectedExceptionMessage Feed DAO is not loaded in UserQuery
*/
public function test__construct_whenFeedQueryAndNoDao_throwsException() {
$this->markTestIncomplete('There is a problem with the exception autoloading. We need to make a better autoloading process');
$query = array('get' => 'c_1');
new FreshRSS_UserQuery($query);
}
public function test__construct_whenFeedQuery_storesFeedParameters() {
$feed_name = 'some feed name';
$feed = $this->getMock('FreshRSS_Feed', array(), array('', false));
$feed->expects($this->atLeastOnce())
[ci] Add Travis (#1619) * [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
7 years ago
->method('name')
->withAnyParameters()
->willReturn($feed_name);
$feed_dao = $this->getMock('FreshRSS_Searchable');
$feed_dao->expects($this->atLeastOnce())
[ci] Add Travis (#1619) * [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
7 years ago
->method('searchById')
->withAnyParameters()
->willReturn($feed);
$query = array('get' => 'f_1');
$user_query = new FreshRSS_UserQuery($query, $feed_dao, null);
$this->assertEquals($feed_name, $user_query->getGetName());
$this->assertEquals('feed', $user_query->getGetType());
}
public function test__construct_whenUnknownQuery_doesStoreParameters() {
$query = array('get' => 'q');
$user_query = new FreshRSS_UserQuery($query);
$this->assertNull($user_query->getGetName());
$this->assertNull($user_query->getGetType());
}
public function test__construct_whenName_storesName() {
$name = 'some name';
$query = array('name' => $name);
$user_query = new FreshRSS_UserQuery($query);
$this->assertEquals($name, $user_query->getName());
}
public function test__construct_whenOrder_storesOrder() {
$order = 'some order';
$query = array('order' => $order);
$user_query = new FreshRSS_UserQuery($query);
$this->assertEquals($order, $user_query->getOrder());
}
public function test__construct_whenState_storesState() {
$state = 'some state';
$query = array('state' => $state);
$user_query = new FreshRSS_UserQuery($query);
$this->assertEquals($state, $user_query->getState());
}
public function test__construct_whenUrl_storesUrl() {
$url = 'some url';
$query = array('url' => $url);
$user_query = new FreshRSS_UserQuery($query);
$this->assertEquals($url, $user_query->getUrl());
}
public function testToArray_whenNoData_returnsEmptyArray() {
$user_query = new FreshRSS_UserQuery(array());
$this->assertInternalType('array', $user_query->toArray());
$this->assertCount(0, $user_query->toArray());
}
public function testToArray_whenData_returnsArray() {
$query = array(
[ci] Add Travis (#1619) * [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
7 years ago
'get' => 's',
'name' => 'some name',
'order' => 'some order',
'search' => 'some search',
'state' => 'some state',
'url' => 'some url',
);
$user_query = new FreshRSS_UserQuery($query);
$this->assertInternalType('array', $user_query->toArray());
$this->assertCount(6, $user_query->toArray());
$this->assertEquals($query, $user_query->toArray());
}
public function testHasSearch_whenSearch_returnsTrue() {
$query = array(
[ci] Add Travis (#1619) * [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
7 years ago
'search' => 'some search',
);
$user_query = new FreshRSS_UserQuery($query);
$this->assertTrue($user_query->hasSearch());
}
public function testHasSearch_whenNoSearch_returnsFalse() {
$user_query = new FreshRSS_UserQuery(array());
$this->assertFalse($user_query->hasSearch());
}
public function testHasParameters_whenAllQuery_returnsFalse() {
$query = array('get' => 'a');
$user_query = new FreshRSS_UserQuery($query);
$this->assertFalse($user_query->hasParameters());
}
public function testHasParameters_whenNoParameter_returnsFalse() {
$query = array();
$user_query = new FreshRSS_UserQuery($query);
$this->assertFalse($user_query->hasParameters());
}
public function testHasParameters_whenParameter_returnTrue() {
$query = array('get' => 's');
$user_query = new FreshRSS_UserQuery($query);
$this->assertTrue($user_query->hasParameters());
}
public function testIsDeprecated_whenCategoryExists_returnFalse() {
$cat = $this->getMock('FreshRSS_Category');
$cat_dao = $this->getMock('FreshRSS_Searchable');
$cat_dao->expects($this->atLeastOnce())
[ci] Add Travis (#1619) * [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
7 years ago
->method('searchById')
->withAnyParameters()
->willReturn($cat);
$query = array('get' => 'c_1');
$user_query = new FreshRSS_UserQuery($query, null, $cat_dao);
$this->assertFalse($user_query->isDeprecated());
}
public function testIsDeprecated_whenCategoryDoesNotExist_returnTrue() {
$cat_dao = $this->getMock('FreshRSS_Searchable');
$cat_dao->expects($this->atLeastOnce())
[ci] Add Travis (#1619) * [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
7 years ago
->method('searchById')
->withAnyParameters()
->willReturn(null);
$query = array('get' => 'c_1');
$user_query = new FreshRSS_UserQuery($query, null, $cat_dao);
$this->assertTrue($user_query->isDeprecated());
}
public function testIsDeprecated_whenFeedExists_returnFalse() {
$feed = $this->getMock('FreshRSS_Feed', array(), array('', false));
$feed_dao = $this->getMock('FreshRSS_Searchable');
$feed_dao->expects($this->atLeastOnce())
[ci] Add Travis (#1619) * [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
7 years ago
->method('searchById')
->withAnyParameters()
->willReturn($feed);
$query = array('get' => 'f_1');
$user_query = new FreshRSS_UserQuery($query, $feed_dao, null);
$this->assertFalse($user_query->isDeprecated());
}
public function testIsDeprecated_whenFeedDoesNotExist_returnTrue() {
$feed_dao = $this->getMock('FreshRSS_Searchable');
$feed_dao->expects($this->atLeastOnce())
[ci] Add Travis (#1619) * [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
7 years ago
->method('searchById')
->withAnyParameters()
->willReturn(null);
$query = array('get' => 'f_1');
$user_query = new FreshRSS_UserQuery($query, $feed_dao, null);
$this->assertTrue($user_query->isDeprecated());
}
public function testIsDeprecated_whenAllQuery_returnFalse() {
$query = array('get' => 'a');
$user_query = new FreshRSS_UserQuery($query);
$this->assertFalse($user_query->isDeprecated());
}
public function testIsDeprecated_whenFavoriteQuery_returnFalse() {
$query = array('get' => 's');
$user_query = new FreshRSS_UserQuery($query);
$this->assertFalse($user_query->isDeprecated());
}
public function testIsDeprecated_whenUnknownQuery_returnFalse() {
$query = array('get' => 'q');
$user_query = new FreshRSS_UserQuery($query);
$this->assertFalse($user_query->isDeprecated());
}
}