public function testTemplates() { $fakeTemplates = array('hello.php' => 'hello there', 'goodbye.php' => 'goodbye now'); $fakeTheme = $this->mock('stdClass'); $fakeTheme->shouldReceive('get_page_templates')->once()->andReturn($fakeTemplates); $this->_mockWpFunctions->shouldReceive('wp_get_theme')->once()->andReturn($fakeTheme); $actual = $this->_sut->getPageTemplates(); $expected = array('index.php' => 'default', 'hello.php' => 'hello there', 'goodbye.php' => 'goodbye now'); $this->assertEquals($expected, $actual); }
public function onWpPostTemplate(tubepress_api_event_EventInterface $event) { $templates = $this->_resourceRepository->getPageTemplates(); unset($templates['index.php']); $templates = $this->_langUtils->arrayUnshiftAssociative($templates, 'index.php', 'default'); $current = $event->getSubject(); if (!is_array($current)) { $current = array(); } $toSet = array_merge($current, $templates); $event->setSubject($toSet); }