Open Journal Systems  3.3.0
GroupTest.php
1 <?php
2 /*
3  * citeproc-php
4  *
5  * @link http://github.com/seboettg/citeproc-php for the source repository
6  * @copyright Copyright (c) 2016 Sebastian Böttger.
7  * @license https://opensource.org/licenses/MIT
8  */
9 
11 
12 use PHPUnit\Framework\TestCase;
17 
18 class GroupTest extends TestCase
19 {
21 
22  private $data = "{\"title\":\"Ein Buch\", \"URL\":\"http://foo.bar\"}";
23 
24  public function setUp()
25  {
26  parent::setUp(); // TODO: Change the autogenerated stub
27  $context = new Context();
28  $context->setLocale(new Locale("de-DE"));
29  CiteProc::setContext($context);
30  }
31 
32  public function testRenderDelimiter()
33  {
34  $str = '<group delimiter=" "><text term="retrieved"/><text term="from"/><text variable="URL"/></group>';
35  $group = new Group(new \SimpleXMLElement($str), null);
36  $this->assertEquals("abgerufen von http://foo.bar", $group->render(json_decode($this->data)));
37  }
38 
39  public function testRenderAffixes()
40  {
41  $str = '<group prefix="[" suffix="]" delimiter=" "><text term="retrieved"/><text term="from"/><text variable="URL"/></group>';
42  $group = new Group(new \SimpleXMLElement($str), null);
43  $this->assertEquals("[abgerufen von http://foo.bar]", $group->render(json_decode($this->data)));
44  }
45 
46  public function testRenderDisplay()
47  {
48  $str = '<group display="indent" prefix="[" suffix="]" delimiter=" "><text term="retrieved"/><text term="from"/><text variable="URL"/></group>';
49  $group = new Group(new \SimpleXMLElement($str), null);
50  $this->assertEquals("<div class=\"csl-indent\">[abgerufen von http://foo.bar]</div>", $group->render(json_decode($this->data)));
51  }
52 
53 
54  public function testGroupComplexNesting()
55  {
56  $this->_testRenderTestSuite("group_ComplexNesting");
57  }
58 
59  public function testGroupShortOutputOnly()
60  {
61  $this->_testRenderTestSuite("group_ShortOutputOnly");
62  }
63 
64  public function testGroupDelimiter()
65  {
66  $this->_testRenderTestSuite("group_Delimiter");
67  }
68 
70  {
71  //TODO: implement
72  $this->_testRenderTestSuite("group_SuppressTermWhenNoOutputFromPartialDate");
73  }
74 
76  {
77  //TODO: implement
78  $this->_testRenderTestSuite("group_SuppressValueWithEmptySubgroup");
79  }
80 
81  /*
82  public function testGroupSuppressWithEmptyNestedDateNode()
83  {
84  //TODO: implement
85  $this->_testRenderTestSuite("group_SuppressWithEmptyNestedDateNode");
86  }
87  */
88 }
Seboettg\CiteProc\TestSuiteTestCaseTrait
trait TestSuiteTestCaseTrait
Definition: TestSuiteTestCaseTrait.php:17
Seboettg\CiteProc\Context
Definition: Context.php:32
Seboettg\CiteProc\Rendering\GroupTest\testGroupComplexNesting
testGroupComplexNesting()
Definition: GroupTest.php:54
Seboettg\CiteProc\Locale\Locale
Definition: Locale.php:33
Seboettg\CiteProc\Rendering\GroupTest\testGroupSuppressValueWithEmptySubgroup
testGroupSuppressValueWithEmptySubgroup()
Definition: GroupTest.php:75
Seboettg\CiteProc\Rendering\GroupTest\testGroupDelimiter
testGroupDelimiter()
Definition: GroupTest.php:64
Seboettg\CiteProc\_testRenderTestSuite
_testRenderTestSuite($filterTests, $ignore=null)
Definition: TestSuiteTestCaseTrait.php:27
Seboettg\CiteProc\Rendering\Group
Definition: Group.php:36
Seboettg\CiteProc\Rendering\GroupTest\testRenderDisplay
testRenderDisplay()
Definition: GroupTest.php:46
Seboettg\CiteProc\CiteProc
Definition: CiteProc.php:32
Seboettg\CiteProc\Rendering\GroupTest\testRenderDelimiter
testRenderDelimiter()
Definition: GroupTest.php:32
Seboettg\CiteProc\Rendering\GroupTest
Definition: GroupTest.php:18
Seboettg\CiteProc\Rendering\GroupTest\testGroupShortOutputOnly
testGroupShortOutputOnly()
Definition: GroupTest.php:59
Seboettg\CiteProc\Rendering
Seboettg\CiteProc\CiteProc\setContext
static setContext($context)
Definition: CiteProc.php:53
Seboettg\CiteProc\Rendering\GroupTest\testSuppressTermWhenNoOutputFromPartialDate
testSuppressTermWhenNoOutputFromPartialDate()
Definition: GroupTest.php:69
Seboettg\CiteProc\Rendering\GroupTest\setUp
setUp()
Definition: GroupTest.php:24
Seboettg\CiteProc\Rendering\GroupTest\testRenderAffixes
testRenderAffixes()
Definition: GroupTest.php:39