1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Scriptotek\Alma\Analytics; |
4
|
|
|
|
5
|
|
|
use Danmichaelo\QuiteSimpleXMLElement\QuiteSimpleXMLElement; |
6
|
|
|
use PhpSpec\ObjectBehavior; |
7
|
|
|
use Scriptotek\Alma\Analytics\Row; |
8
|
|
|
|
9
|
|
|
class RowSpec extends ObjectBehavior |
10
|
|
|
{ |
11
|
|
|
public function let() |
12
|
|
|
{ |
13
|
|
|
// We need to be able to handle missing data, so let's assume we have |
14
|
|
|
// a report with three columns, but that we for this row only got data |
15
|
|
|
// for two of the columns (data missing for Column2). |
16
|
|
|
$xml = QuiteSimpleXMLElement::make('<Row xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"> |
17
|
|
|
<Column0>0</Column0> |
18
|
|
|
<Column1>col1 content</Column1> |
19
|
|
|
<Column3>col3 content</Column3> |
20
|
|
|
</Row>'); |
21
|
|
|
$xml->registerXPathNamespace('rowset', 'urn:schemas-microsoft-com:xml-analysis:rowset'); |
22
|
|
|
$headers = ['mms_id', 'title', 'isbn']; |
23
|
|
|
$this->beConstructedWith($xml, $headers); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function it_is_initializable() |
27
|
|
|
{ |
28
|
|
|
$this->shouldHaveType(Row::class); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function it_should_have_columns_accessible_by_name() |
32
|
|
|
{ |
33
|
|
|
$this->mms_id->shouldBe('col1 content'); |
|
|
|
|
34
|
|
|
$this->title->shouldBe(null); |
|
|
|
|
35
|
|
|
$this->isbn->shouldBe('col3 content'); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function it_should_have_columns_accessible_by_array_key() |
39
|
|
|
{ |
40
|
|
|
$this['mms_id']->shouldBe('col1 content'); |
41
|
|
|
$this['title']->shouldBe(null); |
42
|
|
|
$this['isbn']->shouldBe('col3 content'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function it_should_have_columns_accessible_by_array_index() |
46
|
|
|
{ |
47
|
|
|
$this[0]->shouldBe('col1 content'); |
48
|
|
|
$this[1]->shouldBe(null); |
49
|
|
|
$this[2]->shouldBe('col3 content'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function it_should_be_traversable() |
53
|
|
|
{ |
54
|
|
|
$this->shouldBeAnInstanceOf('Traversable'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function it_should_be_countable() |
58
|
|
|
{ |
59
|
|
|
$this->shouldHaveCount(3); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function it_should_be_serializable_as_array() |
63
|
|
|
{ |
64
|
|
|
$this->toArray()->shouldBeArray(); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.