/** * Tests the addContentType method * * @return void * * @since 3.1 */ public function testAddContentType() { $this->assertThat(FinderIndexerHelper::addContentType('Article'), $this->equalTo('4'), 'Tests that addContentType returns the ID for an already existing type.'); $existingIds = array('1', '2', '3', '4', '5', '6'); $newTypeId = FinderIndexerHelper::addContentType('PHPUnit'); $this->assertFalse(in_array($newTypeId, $existingIds), 'Tests that the new ID does not already exist in the database.'); }
/** * Method to instantiate the indexer adapter. * * @param object &$subject The object to observe. * @param array $config An array that holds the plugin configuration. * * @since 2.5 */ public function __construct(&$subject, $config) { // Get the database object. $this->db = JFactory::getDbo(); // Call the parent constructor. parent::__construct($subject, $config); // Get the type id. $this->type_id = $this->getTypeId(); // Add the content type if it doesn't exist and is set. if (empty($this->type_id) && !empty($this->type_title)) { $this->type_id = FinderIndexerHelper::addContentType($this->type_title, $this->mime); } // Check for a layout override. if ($this->params->get('layout')) { $this->layout = $this->params->get('layout'); } // Get the indexer object $this->indexer = FinderIndexer::getInstance(); }