1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the xAPI package. |
5
|
|
|
* |
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Xabbuh\XApi\Model\Tests; |
13
|
|
|
|
14
|
|
|
use Xabbuh\XApi\Model\Verb; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Christian Flothmann <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class VerbTest extends \PHPUnit_Framework_TestCase |
20
|
|
|
{ |
21
|
|
|
public function testIsVoidVerb() |
22
|
|
|
{ |
23
|
|
|
$verb = new Verb('http://adlnet.gov/expapi/verbs/voided', array('en-US' => 'voided')); |
24
|
|
|
|
25
|
|
|
$this->assertTrue($verb->isVoidVerb()); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testIsVoidVerbWithoutVoidVerb() |
29
|
|
|
{ |
30
|
|
|
$verb = new Verb( |
31
|
|
|
'http://www.adlnet.gov/XAPIprofile/ran(travelled_a_distance)', |
32
|
|
|
array('en-US' => 'ran', 'es' => 'corrió') |
33
|
|
|
); |
34
|
|
|
|
35
|
|
|
$this->assertFalse($verb->isVoidVerb()); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
View Code Duplication |
public function testVerbsEqualWhenTheirPropertiesAreEqual() |
|
|
|
|
39
|
|
|
{ |
40
|
|
|
$verb1 = new Verb('http://adlnet.gov/expapi/verbs/voided', array('en-US' => 'voided')); |
41
|
|
|
$verb2 = new Verb('http://adlnet.gov/expapi/verbs/voided', array('en-US' => 'voided')); |
42
|
|
|
|
43
|
|
|
$this->assertTrue($verb1->equals($verb2)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
View Code Duplication |
public function testVerbsDoNotEqualWhenIdsDiffer() |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
$verb1 = new Verb('http://adlnet.gov/expapi/verbs/voided', array('en-US' => 'voided')); |
49
|
|
|
$verb2 = new Verb('http://adlnet.gov/expapi/verbs/void', array('en-US' => 'voided')); |
50
|
|
|
|
51
|
|
|
$this->assertFalse($verb1->equals($verb2)); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
View Code Duplication |
public function testVerbsDoNotEqualWhenNumberOfDisplaysDiffers() |
|
|
|
|
55
|
|
|
{ |
56
|
|
|
$verb1 = new Verb('http://adlnet.gov/expapi/verbs/voided', array('en-US' => 'voided')); |
57
|
|
|
$verb2 = new Verb('http://adlnet.gov/expapi/verbs/voided', array()); |
58
|
|
|
|
59
|
|
|
$this->assertFalse($verb1->equals($verb2)); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
View Code Duplication |
public function testVerbsDoNotEqualWhenDisplayLanguagesDiffer() |
|
|
|
|
63
|
|
|
{ |
64
|
|
|
$verb1 = new Verb('http://adlnet.gov/expapi/verbs/voided', array('en-US' => 'voided')); |
65
|
|
|
$verb2 = new Verb('http://adlnet.gov/expapi/verbs/voided', array('en-GB' => 'voided')); |
66
|
|
|
|
67
|
|
|
$this->assertFalse($verb1->equals($verb2)); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
View Code Duplication |
public function testVerbsDoNotEqualWhenDisplayValuesDiffer() |
|
|
|
|
71
|
|
|
{ |
72
|
|
|
$verb1 = new Verb('http://adlnet.gov/expapi/verbs/voided', array('en-US' => 'voided')); |
73
|
|
|
$verb2 = new Verb('http://adlnet.gov/expapi/verbs/voided', array('en-US' => 'void')); |
74
|
|
|
|
75
|
|
|
$this->assertFalse($verb1->equals($verb2)); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function testCreateVoidVerb() |
79
|
|
|
{ |
80
|
|
|
$this->assertEquals('http://adlnet.gov/expapi/verbs/voided', Verb::createVoidVerb()->getId()); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.