ILIAS  Release_4_1_x_branch Revision 61804
 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");
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 
88  public function testAnnotation()
89  {
90  include_once './Services/MetaData/classes/class.ilMDAnnotation.php';
91  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
92 
93  $ann = new ilMDAnnotation(1,2,'xxx');
94  $ann->setDescription("desc");
95  $ann->setDescriptionLanguage(new ilMDLanguageItem('en'));
96  $ann->setEntity('ent');
97  $ann->setDate('date');
98  $ret = $ann->save();
99  $this->assertGreaterThan(0,$ret);
100 
101  $ann->setDescription('desc2');
102  $ann->update();
103  $ann->read();
104  $desc = $ann->getDescription();
105  $this->assertEquals('desc2',$desc);
106 
107  $ann->delete();
108  }
109 
115  public function testClassification()
116  {
117  include_once './Services/MetaData/classes/class.ilMDClassification.php';
118  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
119 
120  $ann = new ilMDClassification(1,2,'xxx');
121  $ann->setDescription("desc");
122  $ann->setDescriptionLanguage(new ilMDLanguageItem('en'));
123  $ann->setPurpose('purp');
124  $ret = $ann->save();
125  $this->assertGreaterThan(0,$ret);
126 
127  $ann->setDescription('desc2');
128  $ann->update();
129  $ann->read();
130  $desc = $ann->getDescription();
131  $this->assertEquals('desc2',$desc);
132 
133  $ann->delete();
134  }
135 
140  public function testContribute()
141  {
142  include_once './Services/MetaData/classes/class.ilMDContribute.php';
143  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
144 
145  $con = new ilMDContribute(1,2,'xxx');
146  $con->setDate('date');
147  $con->setRole('ScriptWriter');
148  $ret = $con->save();
149  $this->assertGreaterThan(0,$ret);
150 
151  $con->setDate('desc2');
152  $con->update();
153  $con->read();
154  $desc = $con->getDate();
155  $this->assertEquals('desc2',$desc);
156 
157  $con->delete();
158  }
159 
164  public function testDescription()
165  {
166  include_once './Services/MetaData/classes/class.ilMDDescription.php';
167  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
168 
169  $con = new ilMDDescription(1,2,'xxx');
170  $con->setDescription('date');
171  $con->setDescriptionLanguage(new ilMDLanguageItem('en'));
172  $ret = $con->save();
173  $this->assertGreaterThan(0,$ret);
174 
175  $con->setDescription('desc2');
176  $con->update();
177  $con->read();
178  $desc = $con->getDescription();
179  $this->assertEquals('desc2',$desc);
180 
181  $con->delete();
182  }
183 
188  public function testEducational()
189  {
190  include_once './Services/MetaData/classes/class.ilMDEducational.php';
191  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
192 
193  $con = new ilMDEducational(1,2,'xxx');
194  $con->setDifficulty('Easy');
195  $ret = $con->save();
196  $this->assertGreaterThan(0,$ret);
197 
198  $con->setDifficulty('Medium');
199  $con->update();
200  $con->read();
201  $desc = $con->getDifficulty();
202  $this->assertEquals('Medium',$desc);
203 
204  $con->delete();
205  }
206 
211  public function testEntity()
212  {
213  include_once './Services/MetaData/classes/class.ilMDEntity.php';
214  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
215 
216  $con = new ilMDEntity(1,2,'xxx');
217  $con->setEntity('Easy');
218  $ret = $con->save();
219  $this->assertGreaterThan(0,$ret);
220 
221  $con->setEntity('Medium');
222  $con->update();
223  $con->read();
224  $desc = $con->getEntity();
225  $this->assertEquals('Medium',$desc);
226 
227  $con->delete();
228  }
229 
234  public function testFormat()
235  {
236  include_once './Services/MetaData/classes/class.ilMDFormat.php';
237  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
238 
239  $con = new ilMDFormat(1,2,'xxx');
240  $con->setFormat('Easy');
241  $ret = $con->save();
242  $this->assertGreaterThan(0,$ret);
243 
244  $con->setFormat('Medium');
245  $con->update();
246  $con->read();
247  $desc = $con->getFormat();
248  $this->assertEquals('Medium',$desc);
249 
250  $con->delete();
251  }
252 
257  public function testGeneral()
258  {
259  include_once './Services/MetaData/classes/class.ilMDGeneral.php';
260  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
261 
262  $con = new ilMDGeneral(1,2,'xxx');
263  $con->setCoverage('Easy');
264  $ret = $con->save();
265  $this->assertGreaterThan(0,$ret);
266 
267  $con->setCoverage('Medium');
268  $con->update();
269  $con->read();
270  $desc = $con->getCoverage();
271  $this->assertEquals('Medium',$desc);
272 
273  $con->delete();
274  }
275 
280  public function testIdentifier()
281  {
282  include_once './Services/MetaData/classes/class.ilMDIdentifier.php';
283  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
284 
285  $con = new ilMDIdentifier(1,2,'xxx');
286  $con->setCatalog('Easy');
287  $ret = $con->save();
288  $this->assertGreaterThan(0,$ret);
289 
290  $con->setCatalog('Medium');
291  $con->update();
292  $con->read();
293  $desc = $con->getCatalog();
294  $this->assertEquals('Medium',$desc);
295 
296  $con->delete();
297  }
298 
303  public function testIdentifier_()
304  {
305  include_once './Services/MetaData/classes/class.ilMDIdentifier_.php';
306  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
307 
308  $con = new ilMDIdentifier_(1,2,'xxx');
309  $con->setCatalog('Easy');
310  $ret = $con->save();
311  $this->assertGreaterThan(0,$ret);
312 
313  $con->setCatalog('Medium');
314  $con->update();
315  $con->read();
316  $desc = $con->getCatalog();
317  $this->assertEquals('Medium',$desc);
318 
319  $con->delete();
320  }
321 
326  public function testKeyword()
327  {
328  include_once './Services/MetaData/classes/class.ilMDKeyword.php';
329  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
330 
331  $con = new ilMDKeyword(1,2,'xxx');
332  $con->setKeyword('Easy');
333  $ret = $con->save();
334  $this->assertGreaterThan(0,$ret);
335 
336  $con->setKeyword('Medium');
337  $con->update();
338  $con->read();
339  $desc = $con->getKeyword();
340  $this->assertEquals('Medium',$desc);
341 
342  $con->delete();
343  }
344 
349  public function testLanguage()
350  {
351  include_once './Services/MetaData/classes/class.ilMDLanguage.php';
352  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
353 
354  $con = new ilMDLanguage(1,2,'xxx');
355  $con->setLanguage(new ilMDLanguageItem('en'));
356  $ret = $con->save();
357  $this->assertGreaterThan(0,$ret);
358 
359  $con->setLanguage(new ilMDLanguageItem('de'));
360  $con->update();
361  $con->read();
362  $desc = $con->getLanguageCode();
363  $this->assertEquals('de',$desc);
364 
365  $con->delete();
366  }
367 
372  public function testLifecycle()
373  {
374  include_once './Services/MetaData/classes/class.ilMDLifecycle.php';
375  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
376 
377  $con = new ilMDLifecycle(1,2,'xxx');
378  $con->setVersion(1);
379  $ret = $con->save();
380  $this->assertGreaterThan(0,$ret);
381 
382  $con->setVersion(2);
383  $con->update();
384  $con->read();
385  $desc = $con->getVersion();
386  $this->assertEquals(2,$desc);
387 
388  $con->delete();
389  }
390 
395  public function testLocation()
396  {
397  include_once './Services/MetaData/classes/class.ilMDLocation.php';
398  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
399 
400  $con = new ilMDLocation(1,2,'xxx');
401  $con->setLocation(1);
402  $ret = $con->save();
403  $this->assertGreaterThan(0,$ret);
404 
405  $con->setLocation(2);
406  $con->update();
407  $con->read();
408  $desc = $con->getLocation();
409  $this->assertEquals(2,$desc);
410 
411  $con->delete();
412  }
413 
418  public function testMetaMetadata()
419  {
420  include_once './Services/MetaData/classes/class.ilMDMetaMetadata.php';
421  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
422 
423  $con = new ilMDMetaMetadata(1,2,'xxx');
424  $con->setMetaDataScheme(1);
425  $ret = $con->save();
426  $this->assertGreaterThan(0,$ret);
427 
428  $con->setMetaDataScheme(2);
429  $con->update();
430  $con->read();
431  $desc = $con->getMetaDataScheme();
432  $this->assertEquals('LOM v 1.0',$desc);
433 
434  $con->delete();
435  }
436 
441  public function testRelation()
442  {
443  include_once './Services/MetaData/classes/class.ilMDRelation.php';
444  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
445 
446  $con = new ilMDRelation(1,2,'xxx');
447  $con->setKind('IsVersionOf');
448  $ret = $con->save();
449  $this->assertGreaterThan(0,$ret);
450 
451  $con->setKind('HasVersion');
452  $con->update();
453  $con->read();
454  $desc = $con->getKind();
455  $this->assertEquals('HasVersion',$desc);
456 
457  $con->delete();
458  }
459 
464  public function testRequirement()
465  {
466  include_once './Services/MetaData/classes/class.ilMDRequirement.php';
467  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
468 
469  $con = new ilMDRequirement(1,2,'xxx');
470  $con->setBrowserName('Amaya');
471  $ret = $con->save();
472  $this->assertGreaterThan(0,$ret);
473 
474  $con->setBrowserName('Opera');
475  $con->update();
476  $con->read();
477  $desc = $con->getBrowserName();
478  $this->assertEquals('Opera',$desc);
479 
480  $con->delete();
481  }
482 
487  public function testRights()
488  {
489  include_once './Services/MetaData/classes/class.ilMDRights.php';
490  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
491 
492  $con = new ilMDRights(1,2,'xxx');
493  $con->setDescription('Amaya');
494  $ret = $con->save();
495  $this->assertGreaterThan(0,$ret);
496 
497  $con->setDescription('Opera');
498  $con->update();
499  $con->read();
500  $desc = $con->getDescription();
501  $this->assertEquals('Opera',$desc);
502 
503  $con->delete();
504  }
505 
510  public function testTaxon()
511  {
512  include_once './Services/MetaData/classes/class.ilMDTaxon.php';
513  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
514 
515  $con = new ilMDTaxon(1,2,'xxx');
516  $con->setTaxon('Amaya');
517  $ret = $con->save();
518  $this->assertGreaterThan(0,$ret);
519 
520  $con->setTaxon('Opera');
521  $con->update();
522  $con->read();
523  $desc = $con->getTaxon();
524  $this->assertEquals('Opera',$desc);
525 
526  $con->delete();
527  }
528 
533  public function testTaxonPath()
534  {
535  include_once './Services/MetaData/classes/class.ilMDTaxonPath.php';
536  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
537 
538  $con = new ilMDTaxonPath(1,2,'xxx');
539  $con->setSource('Amaya');
540  $ret = $con->save();
541  $this->assertGreaterThan(0,$ret);
542 
543  $con->setSource('Opera');
544  $con->update();
545  $con->read();
546  $desc = $con->getSource();
547  $this->assertEquals('Opera',$desc);
548 
549  $con->delete();
550  }
551 
556  public function testTechnical()
557  {
558  include_once './Services/MetaData/classes/class.ilMDTechnical.php';
559  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
560 
561  $con = new ilMDTechnical(1,2,'xxx');
562  $con->setSize('Amaya');
563  $ret = $con->save();
564  $this->assertGreaterThan(0,$ret);
565 
566  $con->setSize('Opera');
567  $con->update();
568  $con->read();
569  $desc = $con->getSize();
570  $this->assertEquals('Opera',$desc);
571 
572  $con->delete();
573  }
574 
579  public function testTypicalAgeRange()
580  {
581  include_once './Services/MetaData/classes/class.ilMDTypicalAgeRange.php';
582  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
583 
584  $con = new ilMDTypicalAgeRange(1,2,'xxx');
585  $con->setTypicalAgeRange('12-22');
586  $ret = $con->save();
587  $this->assertGreaterThan(0,$ret);
588 
589  $con->setTypicalAgeRange('12-14');
590  $con->update();
591  $con->read();
592  $desc = $con->getTypicalAgeRange();
593  $this->assertEquals('12-14',$desc);
594 
595  $con->delete();
596  }
597 }
598 ?>