object = new serendipity_event_typesetbuttons('test'); $this->propBag = new serendipity_property_bag(); $this->getEventData(); } /** * Tear down */ public function tearDown() { parent::tearDown(); } /** * Helper method */ protected function getEventData() { $this->eventData = array( 'id' => 1, 'body' => 'Normal body.', 'extended' => 'Extended body.', ); } /** * Example 1 * @test */ public function introspect() { $this->object->introspect($this->propBag); $this->assertEquals('Typeset/Extended Buttons for non-WYSIWYG editors', $this->propBag->get('name')); $this->assertFalse($this->propBag->get('stackable')); } /** * @test */ public function generateContent() { global $serendipity; $serendipity['version'] = '1.7.8'; $title = 'foobar'; // we need to pass this by reference $this->object->generate_content($title); $this->assertEquals('Typeset/Extended Buttons for non-WYSIWYG editors', $title); } /** * @test */ public function wrongEventShouldReturnFalse() { global $serendipity; $serendipity['version'] = '1.7.8'; $this->object->introspect($this->propBag); $this->assertFalse($this->object->event_hook('frontend_comment', $this->propBag, $this->eventData)); } /** * @test */ public function extendedToolbarShouldNotBeAffectedIfWysiwygIsActive() { global $serendipity; $serendipity['version'] = '1.7.8'; $serendipity['wysiwyg'] = true; // WYSIWYG editor is active $this->object->introspect($this->propBag); $result = $this->object->event_hook('backend_entry_toolbar_extended', $this->propBag, $this->eventData); $this->assertFalse($result); } /** * @test */ public function extendedToolbarWithExtendedTextareaShouldOutputButtons() { global $serendipity; $serendipity['version'] = '1.7.8'; $serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive $this->object->introspect($this->propBag); $this->eventData['backend_entry_toolbar_extended:textarea'] = 'serendipity[extended]'; $result = $this->object->event_hook('backend_entry_toolbar_extended', $this->propBag, $this->eventData); $this->expectOutputString($this->getNotXhtml11Output('serendipity[extended]')); $this->assertTrue($result); } /** * @test */ public function extendedToolbarWithExtendedTextareaShouldOutputCustomButtons() { global $serendipity; $serendipity['version'] = '1.7.8'; $serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive $this->object->introspect($this->propBag); $customButtons = <<@| pre@
@
| bash@[geshi lang=bash]@[/geshi]| perl@[geshi lang=perl]@[/geshi]| sql@[geshi lang=sql]@[/geshi]| li@
  • @
  • EOT; $this->object->set_config('custom', $customButtons); $this->eventData['backend_entry_toolbar_extended:textarea'] = 'serendipity[extended]'; $result = $this->object->event_hook('backend_entry_toolbar_extended', $this->propBag, $this->eventData); $this->expectOutputString($this->getNotXhtml11OutputWithCustomButtons('serendipity[extended]')); $this->assertTrue($result); } /** * @test */ public function extendedToolbarWithExtendedTextareaShouldOutputXhtml11Buttons() { global $serendipity; $serendipity['version'] = '1.7.8'; $serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive $this->object->introspect($this->propBag); $this->object->set_config('use_xhtml11', 'no'); $this->eventData['backend_entry_toolbar_extended:textarea'] = 'serendipity[extended]'; $result = $this->object->event_hook('backend_entry_toolbar_extended', $this->propBag, $this->eventData); $this->expectOutputString($this->getXhtml11Output('serendipity[extended]')); $this->assertTrue($result); } /** * @test */ public function extendedToolbarWithCustomTextareaShouldOutputButtons() { global $serendipity; $serendipity['version'] = '1.7.8'; $serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive $this->object->introspect($this->propBag); $this->eventData['backend_entry_toolbar_extended:textarea'] = 'foobar'; $result = $this->object->event_hook('backend_entry_toolbar_extended', $this->propBag, $this->eventData); $this->expectOutputString($this->getNotXhtml11Output('foobar')); $this->assertTrue($result); } /** * @test */ public function extendedToolbarWithBodyTextareaShouldOutputButtons() { global $serendipity; $serendipity['version'] = '1.7.8'; $serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive $this->object->introspect($this->propBag); $this->eventData['backend_entry_toolbar_body:textarea'] = 'serendipity[body]'; $result = $this->object->event_hook('backend_entry_toolbar_body', $this->propBag, $this->eventData); $this->expectOutputString($this->getNotXhtml11Output('serendipity[body]')); $this->assertTrue($result); } /** * @test */ public function disabledButtonsShouldNotBeDisplayed() { global $serendipity; $serendipity['version'] = '2.0.0'; $serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive $this->object->introspect($this->propBag); $this->object->set_config('enable_center', 'no'); $this->object->set_config('enable_strike', 'no'); $this->eventData['backend_entry_toolbar_body:textarea'] = 'serendipity[body]'; $result = $this->object->event_hook('backend_entry_toolbar_body', $this->propBag, $this->eventData); $this->expectOutputString($this->getNotXhtml11OutputWithoutDisabledButtons('serendipity[body]')); $this->assertTrue($result); } /** * @test */ public function disabledButtonsShouldNotBeDisplayedInLegacyMode() { global $serendipity; $serendipity['version'] = '1.7.8'; $serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive $this->object->introspect($this->propBag); $this->object->set_config('enable_center', 'no'); $this->object->set_config('enable_strike', 'no'); $this->eventData['backend_entry_toolbar_body:textarea'] = 'serendipity[body]'; $result = $this->object->event_hook('backend_entry_toolbar_body', $this->propBag, $this->eventData); $this->expectOutputString($this->getNotXhtml11OutputWithoutDisabledButtonsInLegacyMode('serendipity[body]')); $this->assertTrue($result); } /** * @test */ public function extendedToolbarWithCustomBodyTextareaShouldOutputButtons() { global $serendipity; $serendipity['version'] = '1.7.8'; $serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive $this->object->introspect($this->propBag); $this->eventData['backend_entry_toolbar_body:textarea'] = 'foobar'; $result = $this->object->event_hook('backend_entry_toolbar_body', $this->propBag, $this->eventData); $this->expectOutputString($this->getNotXhtml11Output('foobar')); $this->assertTrue($result); } /** * @param string $textarea * @return string */ private function getXhtml11Output($textarea = "serendipity[extended]") { $output = " ','')\" /> ','')\" /> "; return $output; } /** * @param string $textarea * @return string */ private function getNotXhtml11Output($textarea = "serendipity[extended]") { $output = " ','')\" /> ','')\" /> "; return $output; } /** * @param string $textarea * @return string */ private function getNotXhtml11OutputWithoutDisabledButtons($textarea = "serendipity[extended]") { $output = " "; return $output; } /** * @param string $textarea * @return string */ private function getNotXhtml11OutputWithoutDisabledButtonsInLegacyMode($textarea = "serendipity[extended]") { $output = " "; return $output; } /** * @param string $textarea * @return string */ private function getNotXhtml11OutputWithCustomButtons($textarea = "serendipity[extended]") { $output = " ','')\" /> ','')\" />
    ', '')\" /> ', '')\" /> ', '')\" /> "; return $output; } }