| | 13 | public function testConstructor() |
| | 14 | { |
| | 15 | $doc = new csDocument(320, 240, 'Blah', array('baseProfile' => 'foo/bar')); |
| | 16 | $this->assertAttrValueEquals($doc, '/svg:svg/@width', 320); |
| | 17 | $this->assertAttrValueEquals($doc, '/svg:svg/@height', 240); |
| | 18 | $this->assertTextNodeEquals($doc, '/svg:svg/svg:title', 'Blah'); |
| | 19 | $this->assertAttrValueEquals($doc, '/svg:svg/@baseProfile', 'foo/bar'); |
| | 20 | } |
| | 21 | |
| | 22 | public function testCreateElement() |
| | 23 | { |
| | 24 | $doc = new csDocument(320, 240, 'Blah'); |
| | 25 | $this->assertType('csCircle', $doc->createElement('circle')); |
| | 26 | $this->assertType('csRect', $doc->createElement('rect')); |
| | 27 | $this->assertType('csLinearGradient', $doc->createElement('linearGradient')); |
| | 28 | } |
| | 29 | |
| | 30 | public function testDropElementById() |
| | 31 | { |
| | 32 | $doc = new csDocument(320, 240, 'Blah'); |
| | 33 | $c = new csCircle(); |
| | 34 | $c->setRadius(10); |
| | 35 | $c->setStroke('red'); |
| | 36 | $c->setId('circle1'); |
| | 37 | $doc->addElement($c); |
| | 38 | $this->assertNodeExists($doc, '/svg:svg/svg:circle[@id = "circle1"]'); |
| | 39 | $doc->dropElementById('circle1'); |
| | 40 | $this->assertNodeDoesNotExist($doc, '/svg:svg/svg:circle[@id = "circle1"]'); |
| | 41 | } |
| | 42 | |
| | 43 | public function testHasId() |
| | 44 | { |
| | 45 | $doc = new csDocument(320, 240, 'Blah'); |
| | 46 | $c = new csCircle(); |
| | 47 | $c->setRadius(10); |
| | 48 | $c->setStroke('red'); |
| | 49 | $c->setId('circle1'); |
| | 50 | $c2 = clone($c); |
| | 51 | $c2->setId('circle2'); |
| | 52 | $doc->addElement($c); |
| | 53 | $doc->addElement($c2); |
| | 54 | $this->assertTrue($doc->hasId('circle1')); |
| | 55 | $this->assertTrue($doc->hasId('circle2')); |
| | 56 | $this->assertFalse($doc->hasId('jfhkjsdfh')); |
| | 57 | } |
| | 58 | |
| | 92 | public function testSwapDepths() |
| | 93 | { |
| | 94 | $doc = new csDocument(320, 240, 'Test depths'); |
| | 95 | $c1 = new csCircle(160, 120, 40); |
| | 96 | $c1->setDepth(20); |
| | 97 | $c1->setId('c1'); |
| | 98 | $c2 = new csCircle(140, 100, 40); |
| | 99 | $c2->setDepth(40); |
| | 100 | $c2->setId('c2'); |
| | 101 | $doc->addElement($c1); |
| | 102 | $doc->addElement($c2); |
| | 103 | $doc->swapDepths('c1', 'c2'); |
| | 104 | $this->assertAttrValueEquals($doc, '/svg:svg/svg:circle[@id = "c1"]/@style', 'z-index: 40'); |
| | 105 | $this->assertAttrValueEquals($doc, '/svg:svg/svg:circle[@id = "c2"]/@style', 'z-index: 20'); |
| | 106 | } |
| | 107 | |
| | 108 | public function testViewBox() |
| | 109 | { |
| | 110 | $doc = new csDocument(); |
| | 111 | $doc->setViewBox(10, 10, 320, 240); |
| | 112 | $this->assertAttrValueEquals($doc, '/svg:svg/@viewBox', '10 10 320 240'); |
| | 113 | } |
| | 114 | |