ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
SuggestedSolutionTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 
34 {
35  public function getSolution(
36  int $id,
37  int $question_id,
38  string $internal_link,
39  string $import_id,
40  int $subquestion_index,
41  string $type,
42  string $value,
43  DateTimeImmutable $last_update
45  return $this->buildSuggestedSolution(
46  $id,
47  $question_id,
48  $internal_link,
49  $import_id,
50  $subquestion_index,
51  $type,
52  $value,
53  $last_update
54  );
55  }
56 }
57 
59 {
61  protected function setUp(): void
62  {
63  $this->repo = new SuggestedSolutionRepoMock(
64  $this->createMock(ilDBInterface::class),
65  );
66  }
67 
69  {
70  $id = 123;
71  $question_id = 321;
72  $internal_link = '';
73  $import_id = 'imported_xy';
74  $subquestion_index = 0;
75  $type = SuggestedSolution::TYPE_FILE;
76 
77  $values = [
78  'name' => 'something.jpg',
79  'type' => 'image/jpeg',
80  'size' => 120,
81  'filename' => 'actually title of file',
82  ];
83 
84  $last_update = new DateTimeImmutable();
85 
86  $sugsol = $this->repo->getSolution(
87  $id,
88  $question_id,
89  $internal_link,
90  $import_id,
91  $subquestion_index,
92  $type,
93  serialize($values),
94  $last_update,
95  );
96  $this->assertInstanceOf(SuggestedSolution::class, $sugsol);
97  $this->assertInstanceOf(SuggestedSolutionFile::class, $sugsol);
98 
99  $this->assertEquals($values[$sugsol::ARRAY_KEY_TITLE], $sugsol->getTitle());
100  $this->assertEquals($values[$sugsol::ARRAY_KEY_MIME], $sugsol->getMime());
101  $this->assertEquals($values[$sugsol::ARRAY_KEY_SIZE], $sugsol->getSize());
102  $this->assertEquals($values[$sugsol::ARRAY_KEY_FILENAME], $sugsol->getFilename());
103  $this->assertEquals(serialize($values), $sugsol->getStorableValue());
104  $this->assertTrue($sugsol->isOfTypeFile());
105  $this->assertFalse($sugsol->isOfTypeLink());
106 
107  return $sugsol;
108  }
109 
110 
115  {
116  $values = [
117  'name' => 'somethingelse.ico',
118  'type' => 'image/x-icon',
119  'size' => 11,
120  'filename' => '',
121  ];
122 
123  $sugsol = $sugsol
124  ->withTitle($values['filename'])
125  ->withMime($values['type'])
126  ->withSize($values['size'])
127  ->withFilename($values['name']);
128 
129  $this->assertEquals($values['name'], $sugsol->getTitle());
130  $this->assertEquals($values['name'], $sugsol->getFileName());
131  $this->assertEquals($values['type'], $sugsol->getMime());
132  $this->assertEquals($values['size'], $sugsol->getSize());
133 
134  $nu_title = 'another title';
135  $this->assertEquals($nu_title, $sugsol->withTitle($nu_title)->getTitle());
136  }
137 }
test the suggested solution immutable(s)
testSuggestedSolutionMutatorsFile(SuggestedSolutionFile $sugsol)
testSuggestedSolutionFile
SuggestedSolutionRepoMock $repo
buildSuggestedSolution(int $id, int $question_id, string $internal_link, string $import_id, int $subquestion_index, string $type, string $value, \DateTimeImmutable $last_update)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getSolution(int $id, int $question_id, string $internal_link, string $import_id, int $subquestion_index, string $type, string $value, DateTimeImmutable $last_update)