-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#159 Added new unit test (unfinished)
- Loading branch information
Showing
1 changed file
with
33 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,19 +25,13 @@ | |
* along with OPUS; if not, write to the Free Software Foundation, Inc., 51 | ||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* @copyright Copyright (c) 2008-2018, OPUS 4 development team | ||
* @copyright Copyright (c) 2008, OPUS 4 development team | ||
* @license http://www.gnu.org/licenses/gpl.html General Public License | ||
* | ||
* @category Tests | ||
* @package Opus | ||
* @author Ralf Claußnitzer ([email protected]) | ||
* @author Thoralf Klein <[email protected]> | ||
* @author Jens Schwidder <[email protected]> | ||
*/ | ||
|
||
namespace OpusTest; | ||
|
||
use Opus\Document; | ||
use Opus\Common\Document; | ||
use Opus\Licence; | ||
use Opus\Model\DbConstrainViolationException; | ||
use Opus\Model\Xml\Cache; | ||
|
@@ -98,7 +92,7 @@ public function testInvalidateDocumentCache() | |
$lic->setNameLong('MyLongName'); | ||
$lic->setLinkLicence('http://licence.link'); | ||
|
||
$doc = new Document(); | ||
$doc = Document::new(); | ||
$doc->setType("article") | ||
->setServerState('published') | ||
->setLicence($lic); | ||
|
@@ -124,7 +118,7 @@ public function testDocumentServerDateModifiedNotUpdatedWithConfiguredFields() | |
->setLinkLicence('http://test') | ||
->store(); | ||
|
||
$doc = new Document(); | ||
$doc = Document::new(); | ||
$doc->setType("article") | ||
->setServerState('published') | ||
->setLicence($licence); | ||
|
@@ -146,7 +140,7 @@ public function testDocumentServerDateModifiedNotUpdatedWithConfiguredFields() | |
} | ||
|
||
$licence->store(); | ||
$docReloaded = new Document($docId); | ||
$docReloaded = Document::get($docId); | ||
|
||
$this->assertEquals( | ||
(string) $serverDateModified, | ||
|
@@ -350,7 +344,7 @@ public function testIsUsed() | |
|
||
$this->assertFalse($licence->isUsed()); | ||
|
||
$doc = new Document(); | ||
$doc = Document::new(); | ||
$doc->addLicence($licence); | ||
$doc->store(); | ||
|
||
|
@@ -370,13 +364,13 @@ public function testGetDocumentCount() | |
|
||
$this->assertEquals(0, $licence->getDocumentCount()); | ||
|
||
$doc = new Document(); | ||
$doc = Document::new(); | ||
$doc->addLicence($licence); | ||
$doc->store(); | ||
|
||
$this->assertEquals(1, $licence->getDocumentCount()); | ||
|
||
$doc = new Document(); | ||
$doc = Document::new(); | ||
$doc->addLicence($licence); | ||
$doc->store(); | ||
|
||
|
@@ -387,4 +381,29 @@ public function testGetDocumentCount() | |
|
||
$this->assertEquals(1, $licence->getDocumentCount()); | ||
} | ||
|
||
public function testAddLicence() | ||
{ | ||
$licence = Licence::fromArray([ | ||
'NameLong' => 'Licence', | ||
'Name' => 'CC BY', | ||
'LinkLicence' => 'https://www.kobv.de/licence1' | ||
]); | ||
$licenceId = $licence->store(); | ||
|
||
$doc = Document::new(); | ||
$doc->addLicence($licence); | ||
$doc->store(); | ||
|
||
$licences = $doc->getLicence(); | ||
|
||
$this->assertCount(1, $licences); | ||
$this->assertEquals(1, $licence->getId()); | ||
|
||
$this->markTestIncomplete('TODO What is the purpose of this test? getId() provides unexpected result'); | ||
|
||
var_dump($licences[0]->getId()); | ||
|
||
$this->assertEquals($licenceId, $licences[0]->getId()); | ||
} | ||
} |