1<?php
2
3//this has to be set up to right path
4require_once DOKU_INC . 'lib/plugins/latexit/classes/BibHandler.php';
5//this has to be set up to the original pages dir
6define("PAGES", DOKU_INC . 'u44e7ehr22wd/pages');
7
8/**
9 * BibHandler tests for the latexit plugin
10 * To let the testing work, you have to have zotero plugin installed and set up.
11 * You have to have the entries, which are inserted in your zotero repository.
12 *
13 * @group plugin_latexit_classes
14 * @group plugin_latexit
15 * @group plugins
16 */
17class bibhandler_plugin_latexit_test extends DokuWikiTest {
18
19    /**
20     * These plugins will be loaded for testing.
21     * @var array
22     */
23    protected $pluginsEnabled = array('latexit', 'mathjax', 'imagereference', 'zotero');
24
25    /**
26     * Variable to store the instance of the Bibliography Handler.
27     * @var BibHandler
28     */
29    protected $b;
30
31    /**
32     * Prepares the testing environment
33     * @global array $conf Stores configuration information
34     */
35    public function setUp() {
36        global $conf;
37
38        parent::setUp();
39
40        if(!is_dir(DOKU_PLUGIN.'zotero')) {
41            $this->markTestSkipped('Zotero Plugin is not installed');
42            return;
43        }
44
45        //create page folder for zotero sources.
46        $dir = $conf["datadir"] . '/zotero/';
47        if (!file_exists($dir)) {
48            mkdir($dir, 0777, true);
49        }
50
51        //copy zotero sources
52        copy(dirname(PAGES) . '/pages/zotero/sources.txt', $dir . '/sources.txt');
53        $this->b = BibHandler::getInstance();
54    }
55
56    /**
57     * Testing isEmpty method.
58     */
59    public function test_isEmpty() {
60        $this->assertTrue($this->b->isEmpty());
61        //you have to have this entry in your repository!
62        $this->b->insert("bib:agile-manifesto");
63        $this->assertFalse($this->b->isEmpty());
64    }
65
66    /**
67     * Testing getBibtex method.
68     */
69    public function test_getBibtex() {
70        //you have to have this entry in your repository!
71        $this->b->insert("bib:arlow-uml2-up");
72        //this string has to be the bibtex format of your entries
73        $string = "
74@misc{bib:agile-manifesto,
75	title = {Manifesto for Agile Software Development},
76	lccn = {0987},
77	shorttitle = {bib:agile-manifesto},
78	url = {http://agilemanifesto.org},
79	author = {{Kent Beck} and {Mike Beedle} and {Arie van Bennekum} and {Alistair Cockburn} and {Ward Cunningham} and {Martin Fowler} and {James Grenning} and {Jim Highsmith} and {Andrew Hunt} and {Ron Jeffries} and {Jon Kern} and {Brian Marick} and {Robert C. Martin} and {Steve Mellor} and {Ken Schwaber} and {Jeff Sutherland} and {Dave Thomas}},
80	year = {2001},
81	note = {01246},
82	keywords = {agile methodologies, software engineering}
83}
84
85
86@book{bib:arlow-uml2-up,
87	title = {{UML} 2.0 and the Unified Process: Practical Object-Oriented Analysis and Design (2nd Edition)},
88	isbn = {0321321278},
89	lccn = {0000},
90	shorttitle = {bib:arlow-uml2-up},
91	publisher = {Addison-Wesley Professional},
92	author = {Arlow, Jim and Neustadt, Ila},
93	year = {2005},
94	note = {00000},
95	keywords = {modelling, uml}
96}
97
98";
99        $this->assertEquals($string, $this->b->getBibtex());
100    }
101
102}
103