ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilMDTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 {
35  protected $backupGlobals = FALSE;
36 
37  protected function setUp()
38  {
39  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
40  ilUnitUtil::performInitialisation();
41  }
42 
48  public function testCopyright()
49  {
50  include_once './Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php';
51 
52  $cpr = new ilMDCopyrightSelectionEntry(0);
53  $cpr->setTitle("1");
54  $cpr->setDescription("2");
55  $cpr->setLanguage('en');
56  $cpr->setCopyright("3");
57  $cpr->setCosts(true);
58 
59  $cpr->add();
60 
61  $entry = $cpr->getEntryId();
62  $this->assertGreaterThan(0,$entry);
63 
64  $cpr = new ilMDCopyrightSelectionEntry($entry);
65  $ret = $cpr->getTitle();
66  $this->assertEquals($ret,'1');
67 
68  $ret = $cpr->getDescription();
69  $this->assertEquals($ret,'2');
70 
71  $ret = $cpr->getCopyright();
72  $this->assertEquals($ret,'3');
73 
74  $ret = $cpr->getLanguage();
75  $this->assertEquals($ret,'en');
76 
77  $cpr->setTitle('11');
78  $cpr->update();
79 
80  $cpr->delete();
81  }
82 
89  public function testAnnotation()
90  {
91  include_once './Services/MetaData/classes/class.ilMDAnnotation.php';
92  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
93 
94  $ann = new ilMDAnnotation(1,2,'xxx');
95  $ann->setDescription("desc");
96  $ann->setDescriptionLanguage(new ilMDLanguageItem('en'));
97  $ann->setEntity('ent');
98  $ann->setDate('date');
99  $ret = $ann->save();
100  $this->assertGreaterThan(0,$ret);
101 
102  $ann->setDescription('desc2');
103  $ann->update();
104  $ann->read();
105  $desc = $ann->getDescription();
106  $this->assertEquals('desc2',$desc);
107 
108  $ann->delete();
109  }
110 
117  public function testClassification()
118  {
119  include_once './Services/MetaData/classes/class.ilMDClassification.php';
120  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
121 
122  $ann = new ilMDClassification(1,2,'xxx');
123  $ann->setDescription("desc");
124  $ann->setDescriptionLanguage(new ilMDLanguageItem('en'));
125  $ann->setPurpose('purp');
126  $ret = $ann->save();
127  $this->assertGreaterThan(0,$ret);
128 
129  $ann->setDescription('desc2');
130  $ann->update();
131  $ann->read();
132  $desc = $ann->getDescription();
133  $this->assertEquals('desc2',$desc);
134 
135  $ann->delete();
136  }
137 
143  public function testContribute()
144  {
145  include_once './Services/MetaData/classes/class.ilMDContribute.php';
146  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
147 
148  $con = new ilMDContribute(1,2,'xxx');
149  $con->setDate('date');
150  $con->setRole('ScriptWriter');
151  $ret = $con->save();
152  $this->assertGreaterThan(0,$ret);
153 
154  $con->setDate('desc2');
155  $con->update();
156  $con->read();
157  $desc = $con->getDate();
158  $this->assertEquals('desc2',$desc);
159 
160  $con->delete();
161  }
162 
168  public function testDescription()
169  {
170  include_once './Services/MetaData/classes/class.ilMDDescription.php';
171  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
172 
173  $con = new ilMDDescription(1,2,'xxx');
174  $con->setDescription('date');
175  $con->setDescriptionLanguage(new ilMDLanguageItem('en'));
176  $ret = $con->save();
177  $this->assertGreaterThan(0,$ret);
178 
179  $con->setDescription('desc2');
180  $con->update();
181  $con->read();
182  $desc = $con->getDescription();
183  $this->assertEquals('desc2',$desc);
184 
185  $con->delete();
186  }
187 
193  public function testEducational()
194  {
195  include_once './Services/MetaData/classes/class.ilMDEducational.php';
196  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
197 
198  $con = new ilMDEducational(1,2,'xxx');
199  $con->setDifficulty('Easy');
200  $ret = $con->save();
201  $this->assertGreaterThan(0,$ret);
202 
203  $con->setDifficulty('Medium');
204  $con->update();
205  $con->read();
206  $desc = $con->getDifficulty();
207  $this->assertEquals('Medium',$desc);
208 
209  $con->delete();
210  }
211 
217  public function testEntity()
218  {
219  include_once './Services/MetaData/classes/class.ilMDEntity.php';
220  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
221 
222  $con = new ilMDEntity(1,2,'xxx');
223  $con->setEntity('Easy');
224  $ret = $con->save();
225  $this->assertGreaterThan(0,$ret);
226 
227  $con->setEntity('Medium');
228  $con->update();
229  $con->read();
230  $desc = $con->getEntity();
231  $this->assertEquals('Medium',$desc);
232 
233  $con->delete();
234  }
235 
241  public function testFormat()
242  {
243  include_once './Services/MetaData/classes/class.ilMDFormat.php';
244  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
245 
246  $con = new ilMDFormat(1,2,'xxx');
247  $con->setFormat('Easy');
248  $ret = $con->save();
249  $this->assertGreaterThan(0,$ret);
250 
251  $con->setFormat('Medium');
252  $con->update();
253  $con->read();
254  $desc = $con->getFormat();
255  $this->assertEquals('Medium',$desc);
256 
257  $con->delete();
258  }
259 
265  public function testGeneral()
266  {
267  include_once './Services/MetaData/classes/class.ilMDGeneral.php';
268  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
269 
270  $con = new ilMDGeneral(1,2,'xxx');
271  $con->setCoverage('Easy');
272  $ret = $con->save();
273  $this->assertGreaterThan(0,$ret);
274 
275  $con->setCoverage('Medium');
276  $con->update();
277  $con->read();
278  $desc = $con->getCoverage();
279  $this->assertEquals('Medium',$desc);
280 
281  $con->delete();
282  }
283 
289  public function testIdentifier()
290  {
291  include_once './Services/MetaData/classes/class.ilMDIdentifier.php';
292  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
293 
294  $con = new ilMDIdentifier(1,2,'xxx');
295  $con->setCatalog('Easy');
296  $ret = $con->save();
297  $this->assertGreaterThan(0,$ret);
298 
299  $con->setCatalog('Medium');
300  $con->update();
301  $con->read();
302  $desc = $con->getCatalog();
303  $this->assertEquals('Medium',$desc);
304 
305  $con->delete();
306  }
307 
313  public function testIdentifier_()
314  {
315  include_once './Services/MetaData/classes/class.ilMDIdentifier_.php';
316  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
317 
318  $con = new ilMDIdentifier_(1,2,'xxx');
319  $con->setCatalog('Easy');
320  $ret = $con->save();
321  $this->assertGreaterThan(0,$ret);
322 
323  $con->setCatalog('Medium');
324  $con->update();
325  $con->read();
326  $desc = $con->getCatalog();
327  $this->assertEquals('Medium',$desc);
328 
329  $con->delete();
330  }
331 
337  public function testKeyword()
338  {
339  include_once './Services/MetaData/classes/class.ilMDKeyword.php';
340  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
341 
342  $con = new ilMDKeyword(1,2,'xxx');
343  $con->setKeyword('Easy');
344  $ret = $con->save();
345  $this->assertGreaterThan(0,$ret);
346 
347  $con->setKeyword('Medium');
348  $con->update();
349  $con->read();
350  $desc = $con->getKeyword();
351  $this->assertEquals('Medium',$desc);
352 
353  $con->delete();
354  }
355 
361  public function testLanguage()
362  {
363  include_once './Services/MetaData/classes/class.ilMDLanguage.php';
364  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
365 
366  $con = new ilMDLanguage(1,2,'xxx');
367  $con->setLanguage(new ilMDLanguageItem('en'));
368  $ret = $con->save();
369  $this->assertGreaterThan(0,$ret);
370 
371  $con->setLanguage(new ilMDLanguageItem('de'));
372  $con->update();
373  $con->read();
374  $desc = $con->getLanguageCode();
375  $this->assertEquals('de',$desc);
376 
377  $con->delete();
378  }
379 
385  public function testLifecycle()
386  {
387  include_once './Services/MetaData/classes/class.ilMDLifecycle.php';
388  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
389 
390  $con = new ilMDLifecycle(1,2,'xxx');
391  $con->setVersion(1);
392  $ret = $con->save();
393  $this->assertGreaterThan(0,$ret);
394 
395  $con->setVersion(2);
396  $con->update();
397  $con->read();
398  $desc = $con->getVersion();
399  $this->assertEquals(2,$desc);
400 
401  $con->delete();
402  }
403 
409  public function testLocation()
410  {
411  include_once './Services/MetaData/classes/class.ilMDLocation.php';
412  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
413 
414  $con = new ilMDLocation(1,2,'xxx');
415  $con->setLocation(1);
416  $ret = $con->save();
417  $this->assertGreaterThan(0,$ret);
418 
419  $con->setLocation(2);
420  $con->update();
421  $con->read();
422  $desc = $con->getLocation();
423  $this->assertEquals(2,$desc);
424 
425  $con->delete();
426  }
427 
433  public function testMetaMetadata()
434  {
435  include_once './Services/MetaData/classes/class.ilMDMetaMetadata.php';
436  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
437 
438  $con = new ilMDMetaMetadata(1,2,'xxx');
439  $con->setMetaDataScheme(1);
440  $ret = $con->save();
441  $this->assertGreaterThan(0,$ret);
442 
443  $con->setMetaDataScheme(2);
444  $con->update();
445  $con->read();
446  $desc = $con->getMetaDataScheme();
447  $this->assertEquals('LOM v 1.0',$desc);
448 
449  $con->delete();
450  }
451 
457  public function testRelation()
458  {
459  include_once './Services/MetaData/classes/class.ilMDRelation.php';
460  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
461 
462  $con = new ilMDRelation(1,2,'xxx');
463  $con->setKind('IsVersionOf');
464  $ret = $con->save();
465  $this->assertGreaterThan(0,$ret);
466 
467  $con->setKind('HasVersion');
468  $con->update();
469  $con->read();
470  $desc = $con->getKind();
471  $this->assertEquals('HasVersion',$desc);
472 
473  $con->delete();
474  }
475 
481  public function testRequirement()
482  {
483  include_once './Services/MetaData/classes/class.ilMDRequirement.php';
484  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
485 
486  $con = new ilMDRequirement(1,2,'xxx');
487  $con->setBrowserName('Amaya');
488  $ret = $con->save();
489  $this->assertGreaterThan(0,$ret);
490 
491  $con->setBrowserName('Opera');
492  $con->update();
493  $con->read();
494  $desc = $con->getBrowserName();
495  $this->assertEquals('Opera',$desc);
496 
497  $con->delete();
498  }
499 
505  public function testRights()
506  {
507  include_once './Services/MetaData/classes/class.ilMDRights.php';
508  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
509 
510  $con = new ilMDRights(1,2,'xxx');
511  $con->setDescription('Amaya');
512  $ret = $con->save();
513  $this->assertGreaterThan(0,$ret);
514 
515  $con->setDescription('Opera');
516  $con->update();
517  $con->read();
518  $desc = $con->getDescription();
519  $this->assertEquals('Opera',$desc);
520 
521  $con->delete();
522  }
523 
529  public function testTaxon()
530  {
531  include_once './Services/MetaData/classes/class.ilMDTaxon.php';
532  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
533 
534  $con = new ilMDTaxon(1,2,'xxx');
535  $con->setTaxon('Amaya');
536  $ret = $con->save();
537  $this->assertGreaterThan(0,$ret);
538 
539  $con->setTaxon('Opera');
540  $con->update();
541  $con->read();
542  $desc = $con->getTaxon();
543  $this->assertEquals('Opera',$desc);
544 
545  $con->delete();
546  }
547 
553  public function testTaxonPath()
554  {
555  include_once './Services/MetaData/classes/class.ilMDTaxonPath.php';
556  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
557 
558  $con = new ilMDTaxonPath(1,2,'xxx');
559  $con->setSource('Amaya');
560  $ret = $con->save();
561  $this->assertGreaterThan(0,$ret);
562 
563  $con->setSource('Opera');
564  $con->update();
565  $con->read();
566  $desc = $con->getSource();
567  $this->assertEquals('Opera',$desc);
568 
569  $con->delete();
570  }
571 
577  public function testTechnical()
578  {
579  include_once './Services/MetaData/classes/class.ilMDTechnical.php';
580  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
581 
582  $con = new ilMDTechnical(1,2,'xxx');
583  $con->setSize('Amaya');
584  $ret = $con->save();
585  $this->assertGreaterThan(0,$ret);
586 
587  $con->setSize('Opera');
588  $con->update();
589  $con->read();
590  $desc = $con->getSize();
591  $this->assertEquals('Opera',$desc);
592 
593  $con->delete();
594  }
595 
601  public function testTypicalAgeRange()
602  {
603  include_once './Services/MetaData/classes/class.ilMDTypicalAgeRange.php';
604  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
605 
606  $con = new ilMDTypicalAgeRange(1,2,'xxx');
607  $con->setTypicalAgeRange('12-22');
608  $ret = $con->save();
609  $this->assertGreaterThan(0,$ret);
610 
611  $con->setTypicalAgeRange('12-14');
612  $con->update();
613  $con->read();
614  $desc = $con->getTypicalAgeRange();
615  $this->assertEquals('12-14',$desc);
616 
617  $con->delete();
618  }
619 }
620 ?>