Our coding style omits the PHP closing tag at EOF
[awl.git] / tests / myPropertyTest.php
blob218d6c3e00ef0e7e0040f9879926aafcf84a0867
1 <?php
2 /**
3 * Created by JetBrains PhpStorm.
4 * User: milan
5 * Date: 7/8/13
6 * Time: 12:03 PM
7 * To change this template use File | Settings | File Templates.
8 */
10 require_once 'inc/vComponent.php';
12 class vPropertyTest extends PHPUnit_Framework_TestCase {
14 function getData($filename){
15 $file = fopen($filename, 'r');
16 $data = fread($file, filesize($filename));
17 fclose($file);
18 return $data;
21 public function testProperty(){
22 //$heapLines = new HeapLines($this->getData('tests/data/tzid_data.test'));
23 $component = new vComponent($this->getData('tests/data/tzid_data.test'));
24 $property = $component->getPropertyAt(0);
26 $this->assertNotNull($property);
30 public function testPropertyGetName(){
31 //$heapLines = new HeapLines($this->getData('tests/data/tzid_data.test'));
32 $component = new vComponent($this->getData('tests/data/tzid_data.test'));
33 $property = $component->getPropertyAt(0);
35 $this->assertNotNull($property);
37 $name = $property->Name();
38 $this->assertStringStartsWith('PRODID', $name);
43 public function testPropertySetName(){
44 //$heapLines = new HeapLines($this->getData('tests/data/tzid_data.test'));
45 $component = new vComponent($this->getData('tests/data/tzid_data.test'));
46 $property = $component->getPropertyAt(0);
48 $property->Name('abcdef');
49 $name = $property->Name();
50 $this->assertStringStartsWith('ABCDEF', $name);
51 $this->assertFalse($property->isValid());
55 public function testPropertyGetContent(){
56 //$heapLines = new HeapLines($this->getData('tests/data/tzid_data.test'));
57 $component = new vComponent($this->getData('tests/data/tzid_data.test'));
58 $property = $component->getPropertyAt(0);
60 $this->assertNotNull($property);
62 $content = $property->Value();
63 $this->assertStringStartsWith('-//davical.org//NONSGML', $content);
68 public function testPropertySetContnet(){
69 //$heapLines = new HeapLines($this->getData('tests/data/tzid_data.test'));
70 $component = new vComponent($this->getData('tests/data/tzid_data.test'));
71 $property = $component->getPropertyAt(0);
73 $property->Value('abcdef');
74 $content = $property->Value();
75 $this->assertStringStartsWith('abcdef', $content);
76 $this->assertFalse($property->isValid());
80 public function testPropertyRenderFromString(){
81 $property = new vProperty('PRODID:-//davical.org//NONSGML AWL Calendar//EN');
83 $rendered = $property->Render();
84 $this->assertStringStartsWith('PRODID:-//davical.org//NONSGML AWL Calendar//EN', $rendered);
87 public function testPropertyRenderFromParams(){
88 $property = new vProperty();
89 $property->Name('PRODID');
90 $property->Value('-//davical.org//NONSGML AWL Calendar//EN');
91 $rendered = $property->Render();
92 $this->assertStringStartsWith('PRODID:-//davical.org//NONSGML AWL Calendar//EN', $rendered);
95 public function testPropertyRenderFromStringChangeName(){
96 $property = new vProperty('PRODID:-//davical.org//NONSGML AWL Calendar//EN');
98 $property->Name('VERSION');
100 $rendered = $property->Render();
101 $this->assertStringStartsWith('VERSION:', $rendered);
104 public function testSetParameterValue(){
105 $property = new vProperty();
106 $property->SetParameterValue("hello", "world");
109 $value = $property->GetParameterValue("hello");
110 $this->assertStringStartsWith("world", $value);
113 public function testSetParameterValueRender(){
114 $property = new vProperty();
115 $property->Name("universe");
116 $property->SetParameterValue("hello", "world");
119 $value = $property->Render();
120 $this->assertStringStartsWith("UNIVERSE;HELLO=world:", $value);