public function prepareMocks()
 {
     $this->htmlElement = M::mock(SimpleHtmlElement::classname());
     $this->htmlElement->shouldReceive('getOpeningText')->andReturn('<element>');
     $this->htmlElement->shouldReceive('getClosingText')->andReturn('</element>');
     $this->highlight = M::mock(Highlight::classname());
     $this->highlight->shouldReceive('getType')->andReturn(Highlight::MATCH)->byDefault();
     $this->highlight->shouldReceive('getInfoText')->andReturn("<infoText>")->byDefault();
     $this->highlight->shouldReceive('getHtmlElement')->andReturn(null)->byDefault();
     $this->splitPosition = M::mock(SplitPosition::className());
     $this->splitPosition->shouldReceive('getLevel')->andReturn($this->level)->byDefault();
     $this->splitPosition->shouldReceive('getHighlight')->andReturn($this->highlight)->byDefault();
 }
예제 #2
0
 public function testGetCopyrightHighlights()
 {
     $this->testDb->createPlainTables(array(), true);
     $this->testDb->createInheritedTables();
     $uploadDao = M::mock('Fossology\\Lib\\Dao\\UploadDao');
     $uploadDao->shouldReceive('getUploadEntry')->with(1)->andReturn(array('pfile_fk' => 8));
     $uploadDao->shouldReceive('getUploadEntry')->with(2)->andReturn(array('pfile_fk' => 9));
     $copyrightDao = new CopyrightDao($this->dbManager, $uploadDao);
     $noHighlights = $copyrightDao->getHighlights($uploadTreeId = 1);
     assertThat($noHighlights, emptyArray());
     $this->testDb->insertData(array('copyright'));
     $highlights = $copyrightDao->getHighlights($uploadTreeId = 1);
     assertThat($highlights, arrayWithSize(1));
     $highlight0 = $highlights[0];
     assertThat($highlight0, anInstanceOf(Highlight::classname()));
     $this->assertInstanceOf('Fossology\\Lib\\Data\\Highlight', $highlight0);
     assertThat($highlight0->getEnd(), equalTo(201));
     $hilights = $copyrightDao->getHighlights($uploadTreeId = 2);
     assertThat($hilights, arrayWithSize(1));
     $hilight0 = $hilights[0];
     assertThat($hilight0->getStart(), equalTo(0));
 }