1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
<?php
/**
* Created by JetBrains PhpStorm.
* User: milan
* Date: 7/8/13
* Time: 12:03 PM
* To change this template use File | Settings | File Templates.
*/
require_once 'inc/vComponent.php';
// compatibility with phpunit 6
if (!class_exists('\PHPUnit_Framework_TestCase') &&
class_exists('\PHPUnit\Framework\TestCase')) {
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
}
class myPropertyTest extends PHPUnit_Framework_TestCase {
function getData($filename){
$file = fopen($filename, 'r');
$data = fread($file, filesize($filename));
fclose($file);
return $data;
}
public function testProperty(){
//$heapLines = new HeapLines($this->getData('tests/data/tzid_data.test'));
$component = new vComponent($this->getData('tests/data/tzid_data.test'));
$property = $component->getPropertyAt(0);
$this->assertNotNull($property);
}
public function testPropertyGetName(){
//$heapLines = new HeapLines($this->getData('tests/data/tzid_data.test'));
$component = new vComponent($this->getData('tests/data/tzid_data.test'));
$property = $component->getPropertyAt(0);
$this->assertNotNull($property);
$name = $property->Name();
$this->assertStringStartsWith('PRODID', $name);
}
public function testPropertySetName(){
//$heapLines = new HeapLines($this->getData('tests/data/tzid_data.test'));
$component = new vComponent($this->getData('tests/data/tzid_data.test'));
$property = $component->getPropertyAt(0);
$property->Name('abcdef');
$name = $property->Name();
$this->assertStringStartsWith('ABCDEF', $name);
$this->assertFalse($property->isValid());
}
public function testPropertyGetContent(){
//$heapLines = new HeapLines($this->getData('tests/data/tzid_data.test'));
$component = new vComponent($this->getData('tests/data/tzid_data.test'));
$property = $component->getPropertyAt(0);
$this->assertNotNull($property);
$content = $property->Value();
$this->assertStringStartsWith('-//davical.org//NONSGML', $content);
}
public function testPropertySetContnet(){
//$heapLines = new HeapLines($this->getData('tests/data/tzid_data.test'));
$component = new vComponent($this->getData('tests/data/tzid_data.test'));
$property = $component->getPropertyAt(0);
$property->Value('abcdef');
$content = $property->Value();
$this->assertStringStartsWith('abcdef', $content);
$this->assertFalse($property->isValid());
}
public function testPropertyRenderFromString(){
$property = new vProperty('PRODID:-//davical.org//NONSGML AWL Calendar//EN');
$rendered = $property->Render();
$this->assertStringStartsWith('PRODID:-//davical.org//NONSGML AWL Calendar//EN', $rendered);
}
public function testPropertyRenderFromParams(){
$property = new vProperty();
$property->Name('PRODID');
$property->Value('-//davical.org//NONSGML AWL Calendar//EN');
$rendered = $property->Render();
$this->assertStringStartsWith('PRODID:-//davical.org//NONSGML AWL Calendar//EN', $rendered);
}
public function testPropertyRenderFromStringChangeName(){
$property = new vProperty('PRODID:-//davical.org//NONSGML AWL Calendar//EN');
$property->Name('VERSION');
$rendered = $property->Render();
$this->assertStringStartsWith('VERSION:', $rendered);
}
public function testSetParameterValue(){
$property = new vProperty();
$property->SetParameterValue("hello", "world");
$value = $property->GetParameterValue("hello");
$this->assertStringStartsWith("world", $value);
}
public function testSetParameterValueRender(){
$property = new vProperty();
$property->Name("universe");
$property->SetParameterValue("hello", "world");
$value = $property->Render();
$this->assertStringStartsWith("UNIVERSE;HELLO=world:", $value);
}
}
|