Skip to content

Commit fdca4d4

Browse files
committed
Theme: Fix material theme
1 parent 1c92d34 commit fdca4d4

17 files changed

+2760
-28
lines changed

src/PHPDraft/In/Tests/ApibFileParserTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ public function testFilenameSetup()
5151
$this->assertSame(__DIR__ . '/ApibFileParserTest.php', $property->getValue($this->class));
5252
}
5353

54+
/**
55+
* Test if exception when the file doesn't exist
56+
* @expectedException \RuntimeException
57+
* @expectedExceptionCode 1
58+
* @expectedExceptionMessageRegExp "API File not found: [a-zA-Z0-9\/]*\/drafter\/non_existing_including_apib"
59+
*
60+
* @return void
61+
*/
62+
public function testFilenameSetupWrong()
63+
{
64+
$property = $this->reflection->getProperty('filename');
65+
$property->setAccessible(true);
66+
$property->setValue($this->class, TEST_STATICS . '/drafter/non_existing_including_apib');
67+
$this->class->parse();
68+
}
69+
5470
/**
5571
* Test if setup is successful
5672
* @return void

src/PHPDraft/Model/Elements/ArrayStructureElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function parse($object, &$dependencies)
5656
*/
5757
function __toString()
5858
{
59-
$return = '<ul class="list-group">';
59+
$return = '<ul class="list-group mdl-list">';
6060

6161
if (!is_array($this->value))
6262
{
@@ -67,7 +67,7 @@ function __toString()
6767
$type = (in_array($item, self::DEFAULTS)) ? $item : '<a href="#object-' . str_replace(' ', '-',
6868
strtolower($item)) . '">' . $item . '</a>';
6969

70-
$return .= '<li class="list-group-item">' . $type . '</li>';
70+
$return .= '<li class="list-group-item mdl-list__item">' . $type . '</li>';
7171
}
7272

7373
$return .= '</ul>';

src/PHPDraft/Model/Elements/BasicStructureElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ abstract protected function new_instance();
9090
*/
9191
protected function parse_common($object, &$dependencies)
9292
{
93-
$this->key = $object->content->key->content;
94-
$this->type = $object->content->value->element;
93+
$this->key = (isset($object->content->key->content)) ? $object->content->key->content : NULL;
94+
$this->type = (isset($object->content->value->element)) ? $object->content->value->element : NULL;
9595
$this->description = isset($object->meta->description) ? htmlentities($object->meta->description) : NULL;
9696
$this->status =
9797
isset($object->attributes->typeAttributes) ? join(', ', $object->attributes->typeAttributes) : NULL;

src/PHPDraft/Model/Elements/EnumStructureElement.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ class EnumStructureElement extends BasicStructureElement
2020
*/
2121
public function parse($object, &$dependencies)
2222
{
23-
$this->element = (isset($object->element)) ? $object->element : 'array';
23+
$this->element = (isset($object->element)) ? $object->element : 'enum';
2424

2525
$this->parse_common($object, $dependencies);
2626

27+
$this->key = is_null($this->key) ? $object->content : $this->key;
28+
$this->type = is_null($this->type) ? $object->element : $this->type;
29+
2730
if(!isset($object->content->value->content))
2831
{
29-
$this->value = [];
32+
$this->value = $this->key;
3033
return $this;
3134
}
3235

@@ -52,7 +55,14 @@ public function parse($object, &$dependencies)
5255
*/
5356
function __toString()
5457
{
55-
$return = '<ul class="list-group">';
58+
$return = '<ul class="list-group mdl-list">';
59+
60+
if (is_string($this->value))
61+
{
62+
$type = (in_array($this->element, self::DEFAULTS)) ? $this->element : '<a href="#object-' . str_replace(' ', '-',
63+
strtolower($this->element)) . '">' . $this->element . '</a>';
64+
return '<tr><td>' . $this->key . '</td><td><code>' . $type . '</code></td><td>' . $this->description . '</td></tr>';
65+
}
5666

5767
if (!is_array($this->value))
5868
{
@@ -63,7 +73,7 @@ function __toString()
6373
$type = (in_array($item, self::DEFAULTS)) ? $key : '<a href="#object-' . str_replace(' ', '-',
6474
strtolower($item)) . '">' . $key . '</a>';
6575

66-
$return .= '<li class="list-group-item">' . $type . '</li>';
76+
$return .= '<li class="list-group-item mdl-list__item">' . $type . '</li>';
6777
}
6878

6979
$return .= '</ul>';

src/PHPDraft/Model/Elements/Tests/ArrayStructureElementTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,17 @@ public function testToStringWithArray()
187187
{
188188
$this->class->value = ['string', 'int'];
189189
$return = $this->class->__toString();
190-
$this->assertSame('<ul class="list-group"><li class="list-group-item">string</li><li class="list-group-item"><a href="#object-int">int</a></li></ul>', $return);
190+
$this->assertSame('<ul class="list-group mdl-list"><li class="list-group-item mdl-list__item">string</li><li class="list-group-item mdl-list__item"><a href="#object-int">int</a></li></ul>', $return);
191+
}
192+
193+
/**
194+
* Test setup of new instances
195+
*/
196+
public function testToStringWithString()
197+
{
198+
$this->class->value = 'hello';
199+
$return = $this->class->__toString();
200+
$this->assertSame('<span class="example-value pull-right">[ ]</span>', $return);
191201
}
192202

193203
/**
@@ -197,6 +207,6 @@ public function testToStringWithComplexArray()
197207
{
198208
$this->class->value = ['Bike', 'car'];
199209
$return = $this->class->__toString();
200-
$this->assertSame('<ul class="list-group"><li class="list-group-item"><a href="#object-bike">Bike</a></li><li class="list-group-item"><a href="#object-car">car</a></li></ul>', $return);
210+
$this->assertSame('<ul class="list-group mdl-list"><li class="list-group-item mdl-list__item"><a href="#object-bike">Bike</a></li><li class="list-group-item mdl-list__item"><a href="#object-car">car</a></li></ul>', $return);
201211
}
202212
}

src/PHPDraft/Model/Elements/Tests/EnumStructureElementTest.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,31 @@ public function testToStringWithArray()
6464
{
6565
$this->class->value = ['hello'=>'string', 'test'=>'int'];
6666
$return = $this->class->__toString();
67-
$this->assertSame('<ul class="list-group"><li class="list-group-item">hello</li><li class="list-group-item"><a href="#object-int">test</a></li></ul>', $return);
67+
$this->assertSame('<ul class="list-group mdl-list"><li class="list-group-item mdl-list__item">hello</li><li class="list-group-item mdl-list__item"><a href="#object-int">test</a></li></ul>', $return);
68+
}
69+
70+
/**
71+
* Test setup of new instances
72+
*/
73+
public function testToStringWithString()
74+
{
75+
$this->class->value = 'hello';
76+
$this->class->key = 'key';
77+
$this->class->element = 'string';
78+
$return = $this->class->__toString();
79+
$this->assertSame('<tr><td>key</td><td><code>string</code></td><td></td></tr>', $return);
80+
}
81+
82+
/**
83+
* Test setup of new instances
84+
*/
85+
public function testToStringWithStringComplex()
86+
{
87+
$this->class->value = 'hello';
88+
$this->class->key = 'key';
89+
$this->class->element = 'Car';
90+
$return = $this->class->__toString();
91+
$this->assertSame('<tr><td>key</td><td><code><a href="#object-car">Car</a></code></td><td></td></tr>', $return);
6892
}
6993

7094
/**
@@ -74,7 +98,7 @@ public function testToStringWithComplexArray()
7498
{
7599
$this->class->value = ['hello'=>'bike', 'test'=>'Car'];
76100
$return = $this->class->__toString();
77-
$this->assertSame('<ul class="list-group"><li class="list-group-item"><a href="#object-bike">hello</a></li><li class="list-group-item"><a href="#object-car">test</a></li></ul>', $return);
101+
$this->assertSame('<ul class="list-group mdl-list"><li class="list-group-item mdl-list__item"><a href="#object-bike">hello</a></li><li class="list-group-item mdl-list__item"><a href="#object-car">test</a></li></ul>', $return);
78102
}
79103

80104
/**
@@ -122,7 +146,7 @@ public function parseObjectProvider()
122146

123147
$base3 = new EnumStructureElement();
124148
$base3->key = 'car_id_list';
125-
$base3->value = [];
149+
$base3->value = 'car_id_list';
126150
$base3->status = 'optional';
127151
$base3->element = 'member';
128152
$base3->type = 'array';

src/PHPDraft/Model/Tests/CategoryTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,26 @@ public function testParseIsCalledObject()
104104
$this->assertNotEmpty($s_property->getValue($this->class));
105105
}
106106

107+
/**
108+
* Test basic parse functions where 'element=dataStructure'
109+
*/
110+
public function testParseIsCalledObjectMetaID()
111+
{
112+
$property = $this->reflection->getProperty('parent');
113+
$property->setAccessible(TRUE);
114+
$property->setValue($this->class, $this->parent);
115+
116+
$json = '{"content":[{"element":"dataStructure", "content":[{"meta":{"id":4}, "key":{"content":"none"}, "value":{"element":"none"}}]}]}';
117+
118+
$this->class->parse(json_decode($json));
119+
120+
$this->assertSame($this->parent, $property->getValue($this->class));
121+
122+
$s_property = $this->reflection->getProperty('structures');
123+
$s_property->setAccessible(TRUE);
124+
$this->assertNotEmpty($s_property->getValue($this->class));
125+
}
126+
107127
/**
108128
* Test basic parse functions where 'element=henk'
109129
*/

src/PHPDraft/Model/Tests/ResourceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testParseIsCalledIsCopy()
106106
$property->setAccessible(TRUE);
107107
$property->setValue($this->class, $this->parent);
108108

109-
$obj = '{"content":[{"element":"copy", "content":""},{"element":"hello", "content":""}]}';
109+
$obj = '{"content":[{"element":"copy", "content":""},{"element":"hello", "content":""}, {"element":"hello", "content":""}]}';
110110

111111
$this->class->parse(json_decode($obj));
112112

src/PHPDraft/Model/Tests/TransitionTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,26 @@ public function testParseIsCalledIsArrayContentResponse()
209209
$this->assertSame('something', $href_property->getValue($this->class));
210210
}
211211

212+
/**
213+
* Test basic parse functions
214+
*/
215+
public function testParseIsCalledIsArrayContentDefault()
216+
{
217+
$property = $this->reflection->getProperty('parent');
218+
$property->setAccessible(TRUE);
219+
$property->setValue($this->class, $this->parent);
220+
221+
$obj = '{"attributes":{"href":"something", "data":"hello"}, "content":[{"element":"123", "content":[{"element":"Cow", "content":[], "attributes":{"statusCode":"1000", "headers":{"content":[]}}}]}]}';
222+
223+
$this->class->parse(json_decode($obj));
224+
225+
$this->assertSame($this->parent, $property->getValue($this->class));
226+
227+
$href_property = $this->reflection->getProperty('href');
228+
$href_property->setAccessible(TRUE);
229+
$this->assertSame('something', $href_property->getValue($this->class));
230+
}
231+
212232
/**
213233
* Test basic parse functions
214234
*/

src/PHPDraft/Out/HTML/material.css

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,82 @@ table.table p {
5757
margin-bottom: 0px;
5858
}
5959

60+
div .mdl-card__supporting-text table {
61+
width: 100%;
62+
max-width: 100%;
63+
border: 0px solid #000000;
64+
}
65+
66+
div .mdl-card__supporting-text {
67+
width: 96%;
68+
padding: 2%;
69+
}
70+
71+
.mdl-card__supporting-text .list-group-item.mdl-list__item{
72+
padding: 8px;
73+
width: 100%;
74+
clear: both;
75+
display: block;
76+
text-align: end;
77+
font-size: 13px;
78+
border-bottom: 1px solid #cccccc;
79+
line-height: 31px;
80+
}
81+
82+
.mdl-card__supporting-text .list-group-item.mdl-list__item:last-of-type{
83+
border-bottom: 0px solid #cccccc;
84+
}
85+
6086
.showSearch {
6187
background: #122b40 center / cover;
6288
color: #cccccc;
89+
}
90+
91+
dialog {
92+
position: absolute;
93+
right: 100%;
94+
width: 1000px !important;
95+
height: -moz-fit-content;
96+
height: -webkit-fit-content;
97+
height: fit-content;
98+
margin: auto;
99+
margin-left: -400px;
100+
border: solid;
101+
padding: 1em;
102+
background: white;
103+
color: black;
104+
display: block;
105+
}
106+
107+
dialog textarea {
108+
width: 100%;
109+
max-width: 100%;
110+
line-break: strict;
111+
word-break: break-all;
112+
border-color: #cccccc;
113+
height: 100%;
114+
}
115+
dialog .mdl-textfield {
116+
width: 100%;
117+
}
118+
119+
dialog:not([open]) {
120+
display: none;
121+
}
122+
123+
dialog + .backdrop {
124+
position: fixed;
125+
top: 0; right: 0; bottom: 0; left: 0;
126+
background: rgba(0,0,0,0.1);
127+
}
128+
129+
._dialog_overlay {
130+
position: fixed;
131+
top: 0; right: 0; bottom: 0; left: 0;
132+
}
133+
134+
dialog.fixed {
135+
position: fixed;
136+
top: 50%;
137+
transform: translate(0, -50%);
63138
}

0 commit comments

Comments
 (0)