15 public $fo_copyright_list_path;
19 private $testInstaller;
21 protected function setUp() :
void
23 $this->testDb =
new TestPgDb(
"fossclitest");
24 $tables = array(
'users',
'upload',
'uploadtree_a',
'uploadtree',
'copyright',
'groups',
'group_user_member',
'agent',
'copyright_decision',
'copyright_ars',
'ars_master',
'copyright_event');
25 $this->testDb->createPlainTables($tables);
26 $this->testDb->createInheritedTables(array(
'uploadtree_a'));
27 $this->testDb->createInheritedArsTables(array(
'copyright'));
28 $this->testDb->insertData($tables);
29 $this->testDb->setupSysconfig();
31 $sysConf = $this->testDb->getFossSysConf();
33 $target = dirname(__DIR__, 3) .
'/build/src/cli/gen/fo_wrapper.php';
34 $link = dirname(__DIR__) .
'/fo_copyright_list';
35 if (file_exists($link)) {
38 symlink($target, $link);
39 $this->fo_copyright_list_path =
"$link -c $sysConf";
42 $this->testInstaller->init();
45 protected function tearDown() :
void
47 unlink(dirname(__DIR__) .
"/fo_copyright_list");
48 $this->testInstaller->clear();
49 $this->testDb->fullDestruct();
54 function test_get_copyright_list_all()
57 $auth =
"--user fossy --password fossy";
59 $command =
"$this->fo_copyright_list_path $auth -u $upload_id -t $uploadtree_id --container 1";
60 exec(
"$command 2>&1", $output, $return_value);
62 $this->assertEquals(0, $return_value,
"Non-zero exit status code with\n" . join(
'\n', $output));
63 $this->assertEquals(27, count($output));
64 $this->assertEquals(
"B.zip/B/1b/AAL_B: copyright (c) 2002 by author", $output[22]);
67 function test_get_copyright_list_email()
70 $auth =
"--user fossy --password fossy";
72 $command =
"$this->fo_copyright_list_path $auth -u $upload_id -t $uploadtree_id --type email --container 1";
73 exec(
"$command 2>&1", $output, $return_value);
75 $this->assertEquals(0, $return_value,
"Non-zero exit status code with\n" . join(
'\n', $output));
76 $this->assertEquals(
"B.zip/B/1b/3DFX_B: info@3dfx.com", $output[7]);
79 function test_get_copyright_list_withoutContainer()
82 $auth =
"--user fossy --password fossy";
84 $command =
"$this->fo_copyright_list_path $auth -u $upload_id -t $uploadtree_id --type email --container 0";
85 exec(
"$command 2>&1", $output, $return_value);
87 $this->assertEquals(0, $return_value,
"Non-zero exit status code with\n" . join(
'\n', $output));
88 $this->assertEquals(
"B.zip/B/1b/3DFX_B: info@3dfx.com", $output[4]);
91 public function test_help()
93 $auth =
"--user fossy --password fossy";
94 $command =
"$this->fo_copyright_list_path $auth -h";
95 exec(
"$command 2>&1", $output, $return_value);
97 $this->assertEquals(0, $return_value,
"Non-zero exit status code with\n" . join(
'\n', $output));
98 $this->assertEquals(11, count($output));
101 public function test_help_noAuthentication()
103 $command =
"$this->fo_copyright_list_path -h";
104 exec(
"$command 2>&1", $output, $return_value);
106 $this->assertEquals(0, $return_value,
"Non-zero exit status code with\n" . join(
'\n', $output));
107 $this->assertEquals(11, count($output));