26 include_once(dirname(dirname(__DIR__)).
"/common-string.php");
30 public function __construct($groupBy =
"content")
32 parent::__construct($groupBy);
35 protected function getStatements($uploadId, $uploadTreeTableName, $userId = null, $groupId=null)
38 array(
"licenseId" =>
"371",
"risk" =>
"5",
"content" =>
"1",
"text" =>
"t1",
"comments" =>
"c1",
"uploadtree_pk" => 1),
39 array(
"licenseId" =>
"213",
"risk" =>
"4",
"content" =>
"1",
"text" =>
"t2",
"comments" =>
"c1",
"uploadtree_pk" => 2),
40 array(
"licenseId" =>
"243",
"risk" =>
"4",
"content" =>
"2",
"text" =>
"t3",
"comments" =>
"c3",
"uploadtree_pk" => 3),
47 public function __construct($groupBy =
"content")
49 parent::__construct($groupBy);
52 protected function getStatements($uploadId, $uploadTreeTableName, $userId = null, $groupId=null)
56 public function getCleared($uploadId, $groupId = null, $extended =
true, $agentcall = null, $isUnifiedReport =
false, $objectAgent)
59 array(
"good" =>
"漢",
"esc" =>
"escape",
"uml" =>
' ü ')
71 protected function setUp()
73 $this->uploadDao = M::mock(UploadDao::class);
74 $this->treeDao = M::mock(TreeDao::class);
76 $container = M::mock(
'ContainerBuilder');
77 $GLOBALS[
'container'] = $container;
79 $container->shouldReceive(
'get')->with(
'dao.upload')->andReturn($this->uploadDao);
80 $container->shouldReceive(
'get')->with(
'dao.tree')->andReturn($this->treeDao);
81 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
84 protected function tearDown()
86 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
89 public function testGetFileNames()
95 $uploadTreeTableName =
"ut";
98 ->shouldReceive(
'getUploadtreeTableName')
100 ->andReturn($uploadTreeTableName);
103 ->shouldReceive(
'getMinimalCoveringItem')
104 ->with($uploadId,$uploadTreeTableName)
105 ->andReturn($parentId);
108 ->shouldReceive(
'getFullPath')
109 ->with(1, $uploadTreeTableName, $parentId)
113 ->shouldReceive(
'getFullPath')
114 ->with(2, $uploadTreeTableName, $parentId)
118 ->shouldReceive(
'getFullPath')
119 ->with(3, $uploadTreeTableName, $parentId)
120 ->andReturn(
"a/b/1");
122 $statements = $this->clearedGetterTest->getCleared($uploadId,null,
true,null,
false,null);
124 "statements" => array(
126 "licenseId" =>
"371",
131 "files" => array(
"a/1",
"a/2")
134 "licenseId" =>
"243",
139 "files" => array(
"a/b/1")
143 $expected = arsort($expected);
144 assertThat($expected, equalTo($statements));
147 public function testGetFileNamesGroupByText()
152 $uploadTreeTableName =
"ut";
155 ->shouldReceive(
'getUploadtreeTableName')
157 ->andReturn($uploadTreeTableName);
160 ->shouldReceive(
'getMinimalCoveringItem')
161 ->with($uploadId,$uploadTreeTableName)
162 ->andReturn($parentId);
165 ->shouldReceive(
'getFullPath')
166 ->with(1, $uploadTreeTableName, $parentId)
170 ->shouldReceive(
'getFullPath')
171 ->with(2, $uploadTreeTableName, $parentId)
175 ->shouldReceive(
'getFullPath')
176 ->with(3, $uploadTreeTableName, $parentId)
177 ->andReturn(
"a/b/1");
180 $statements = $tester->getCleared($uploadId,null,
true,null,
false,null);
182 "statements" => array(
184 "licenseId" =>
"371",
189 "files" => array(
"a/1")
192 "licenseId" =>
"213",
197 "files" => array(
"a/2")
200 "licenseId" =>
"243",
205 "files" => array(
"a/b/1")
209 $expected = arsort($expected);
210 assertThat($expected, equalTo($statements));
213 function testWeirdChars()
215 $weirdCharclearedGetter =
new WeirdCharclearedGetter();
216 $json = $weirdCharclearedGetter->cJson(0);
217 assertThat($json, containsString(
'"good":"\\u6f22"'));
218 assertThat($json, containsString(
'"esc":"escape"'));
219 assertThat($json, containsString(
'"uml":" \\u00fc "'));