1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Owncloud\Updater\Tests\Utils; |
4
|
|
|
|
5
|
|
|
use Owncloud\Updater\Utils\Feed; |
6
|
|
|
|
7
|
|
|
class FeedTest extends \PHPUnit_Framework_TestCase { |
8
|
|
|
|
9
|
|
|
public function resultProvider(){ |
10
|
|
|
return [ |
11
|
|
|
[ [], false ], |
12
|
|
|
[ [ 'url'=>'123' ], false ], |
13
|
|
|
[ [ 'url'=>'123', 'version' => '123' ], false ], |
14
|
|
|
[ [ 'url'=>'123', 'version' => '123', 'versionstring' => '123' ], true ], |
15
|
|
|
]; |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @dataProvider resultProvider |
20
|
|
|
*/ |
21
|
|
|
public function testValidity($feedData, $expectedValidity){ |
22
|
|
|
$feed = new Feed($feedData); |
23
|
|
|
$this->assertEquals($expectedValidity, $feed->isValid()); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function feedFileNameProvider(){ |
27
|
|
|
return [ |
28
|
|
|
[ [ 'url'=>'http://example.org/package.zip', 'version' => '1.2.3', 'versionstring' => '1.2.3' ], '1.2.3.zip' ], |
29
|
|
|
[ [ 'url'=>'https://download.owncloud.org/community/owncloud-daily-master.tar.bz2', 'version' => '1.2.3', 'versionstring' => '1.2.3' ], '1.2.3.tar.bz2' ], |
30
|
|
|
]; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @dataProvider feedFileNameProvider |
35
|
|
|
*/ |
36
|
|
|
public function testGetDowngetDownloadedFileName($feedData, $filename){ |
37
|
|
|
$feed = new Feed($feedData); |
38
|
|
|
$this->assertEquals($filename, $feed->getDownloadedFileName()); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|