FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
UploadTest.php
1 <?php
2 /*
3 Copyright (C) 2014-2015, Siemens AG
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 version 2 as published by the Free Software Foundation.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
20 
21 class UploadTest extends \PHPUnit\Framework\TestCase
22 {
24  private $id = 132;
26  private $fileName = "<fileName>";
28  private $description = "<description>";
30  private $treeTableName = "<treeTableName>";
32  private $timestamp;
34  private $upload;
35 
36  protected function setUp()
37  {
38  $this->timestamp = time();
39  $this->upload = new Upload($this->id, $this->fileName, $this->description, $this->treeTableName, $this->timestamp);
40 
41  $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
42  }
43 
44  protected function tearDown()
45  {
46  $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
47  }
48 
49  public function testGetId()
50  {
51  assertThat($this->upload->getId(), is($this->id));
52  }
53 
54  public function testGetFilename()
55  {
56  assertThat($this->upload->getFilename(), is($this->fileName));
57  }
58 
59  public function testGetDescription()
60  {
61  assertThat($this->upload->getDescription(), is($this->description));
62  }
63 
64  public function testGetTreeTableName()
65  {
66  assertThat($this->upload->getTreeTableName(), is($this->treeTableName));
67  }
68 
69  public function testGetTimeStamp()
70  {
71  assertThat($this->upload->getTimestamp(), is($this->timestamp));
72  }
73 
74  public function testCreateFromTableRow()
75  {
76  $row = array(
77  'upload_pk' => $this->id,
78  'upload_filename' => $this->fileName,
79  'upload_desc' => $this->description,
80  'uploadtree_tablename' => $this->treeTableName,
81  'upload_ts' => date('Y-m-d H:i:s',$this->timestamp)
82  );
83 
84  $upload = Upload::createFromTable($row);
85  assertThat($upload->getId(), is($this->id));
86  assertThat($upload->getFilename(), is($this->fileName));
87  assertThat($upload->getDescription(), is($this->description));
88  assertThat($upload->getTreeTableName(), is($this->treeTableName));
89  assertThat($upload->getTimestamp(), is($this->timestamp));
90  }
91 }