Best Atoum code snippet using aggregator
aggregator.processor.inc
Source:aggregator.processor.inc
1<?php2/**3 * @file4 * Processor functions for the aggregator module.5 */6/**7 * Implements hook_aggregator_process_info().8 */9function aggregator_aggregator_process_info() {10 return array(11 'title' => t('Default processor'),12 'description' => t('Creates lightweight records from feed items.'),13 );14}15/**16 * Implements hook_aggregator_process().17 */18function aggregator_aggregator_process($feed) {19 if (is_object($feed)) {20 if (is_array($feed->items)) {21 foreach ($feed->items as $item) {22 // Save this item. Try to avoid duplicate entries as much as possible. If23 // we find a duplicate entry, we resolve it and pass along its ID is such24 // that we can update it if needed.25 if (!empty($item['guid'])) {26 $entry = db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = :fid AND guid = :guid", array(':fid' => $feed->fid, ':guid' => $item['guid']))->fetchObject();27 }28 elseif ($item['link'] && $item['link'] != $feed->link && $item['link'] != $feed->url) {29 $entry = db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = :fid AND link = :link", array(':fid' => $feed->fid, ':link' => $item['link']))->fetchObject();30 }31 else {32 $entry = db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = :fid AND title = :title", array(':fid' => $feed->fid, ':title' => $item['title']))->fetchObject();33 }34 if (!$item['timestamp']) {35 $item['timestamp'] = isset($entry->timestamp) ? $entry->timestamp : REQUEST_TIME;36 }37 // Make sure the item title and author fit in the 255 varchar column.38 $item['title'] = truncate_utf8($item['title'], 255, TRUE, TRUE);39 $item['author'] = truncate_utf8($item['author'], 255, TRUE, TRUE);40 aggregator_save_item(array('iid' => (isset($entry->iid) ? $entry->iid : ''), 'fid' => $feed->fid, 'timestamp' => $item['timestamp'], 'title' => $item['title'], 'link' => $item['link'], 'author' => $item['author'], 'description' => $item['description'], 'guid' => $item['guid']));41 }42 }43 }44}45/**46 * Implements hook_aggregator_remove().47 */48function aggregator_aggregator_remove($feed) {49 $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchCol();50 if ($iids) {51 db_delete('aggregator_category_item')52 ->condition('iid', $iids, 'IN')53 ->execute();54 }55 db_delete('aggregator_item')56 ->condition('fid', $feed->fid)57 ->execute();58 drupal_set_message(t('The news items from %site have been removed.', array('%site' => $feed->title)));59}60/**61 * Implements hook_form_aggregator_admin_form_alter().62 *63 * Form alter aggregator module's own form to keep processor functionality64 * separate from aggregator API functionality.65 */66function aggregator_form_aggregator_admin_form_alter(&$form, $form_state) {67 if (in_array('aggregator', variable_get('aggregator_processors', array('aggregator')))) {68 $info = module_invoke('aggregator', 'aggregator_process', 'info');69 $items = drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items');70 $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');71 $period[AGGREGATOR_CLEAR_NEVER] = t('Never');72 // Only wrap into a collapsible fieldset if there is a basic configuration.73 if (isset($form['basic_conf'])) {74 $form['modules']['aggregator'] = array(75 '#type' => 'fieldset',76 '#title' => t('Default processor settings'),77 '#description' => $info['description'],78 '#collapsible' => TRUE,79 '#collapsed' => !in_array('aggregator', variable_get('aggregator_processors', array('aggregator'))),80 );81 }82 else {83 $form['modules']['aggregator'] = array();84 }85 $form['modules']['aggregator']['aggregator_summary_items'] = array(86 '#type' => 'select',87 '#title' => t('Number of items shown in listing pages'),88 '#default_value' => variable_get('aggregator_summary_items', 3),89 '#empty_value' => 0,90 '#options' => $items,91 );92 $form['modules']['aggregator']['aggregator_clear'] = array(93 '#type' => 'select',94 '#title' => t('Discard items older than'),95 '#default_value' => variable_get('aggregator_clear', 9676800),96 '#options' => $period,97 '#description' => t('Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),98 );99 $form['modules']['aggregator']['aggregator_category_selector'] = array(100 '#type' => 'radios',101 '#title' => t('Select categories using'),102 '#default_value' => variable_get('aggregator_category_selector', 'checkboxes'),103 '#options' => array('checkboxes' => t('checkboxes'),104 'select' => t('multiple selector')),105 '#description' => t('For a small number of categories, checkboxes are easier to use, while a multiple selector works well with large numbers of categories.'),106 );107 $form['modules']['aggregator']['aggregator_teaser_length'] = array(108 '#type' => 'select',109 '#title' => t('Length of trimmed description'),110 '#default_value' => variable_get('aggregator_teaser_length', 600),111 '#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_aggregator_characters'),112 '#description' => t("The maximum number of characters used in the trimmed version of content.")113 );114 }115}116/**117 * Creates display text for teaser length option values.118 *119 * Callback for drupal_map_assoc() within120 * aggregator_form_aggregator_admin_form_alter().121 *122 * @param $length123 * The desired length of teaser text, in bytes.124 *125 * @return126 * A translated string explaining the teaser string length.127 */128function _aggregator_characters($length) {129 return ($length == 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters');130}131/**132 * Adds/edits/deletes an aggregator item.133 *134 * @param $edit135 * An associative array describing the item to be added/edited/deleted.136 */137function aggregator_save_item($edit) {138 if ($edit['title'] && empty($edit['iid'])) {139 $edit['iid'] = db_insert('aggregator_item')140 ->fields(array(141 'title' => $edit['title'],142 'link' => $edit['link'],143 'author' => $edit['author'],144 'description' => $edit['description'],145 'guid' => $edit['guid'],146 'timestamp' => $edit['timestamp'],147 'fid' => $edit['fid'],148 ))149 ->execute();150 }151 if ($edit['iid'] && !$edit['title']) {152 db_delete('aggregator_item')153 ->condition('iid', $edit['iid'])154 ->execute();155 db_delete('aggregator_category_item')156 ->condition('iid', $edit['iid'])157 ->execute();158 }159 elseif ($edit['title'] && $edit['link']) {160 // file the items in the categories indicated by the feed161 $result = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = :fid', array(':fid' => $edit['fid']));162 foreach ($result as $category) {163 db_merge('aggregator_category_item')164 ->key(array(165 'iid' => $edit['iid'],166 'cid' => $category->cid,167 ))168 ->execute();169 }170 }171}172/**173 * Expires items from a feed depending on expiration settings.174 *175 * @param $feed176 * Object describing feed.177 */178function aggregator_expire($feed) {179 $aggregator_clear = variable_get('aggregator_clear', 9676800);180 if ($aggregator_clear != AGGREGATOR_CLEAR_NEVER) {181 // Remove all items that are older than flush item timer.182 $age = REQUEST_TIME - $aggregator_clear;183 $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid AND timestamp < :timestamp', array(184 ':fid' => $feed->fid,185 ':timestamp' => $age,186 ))187 ->fetchCol();188 if ($iids) {189 db_delete('aggregator_category_item')190 ->condition('iid', $iids, 'IN')191 ->execute();192 db_delete('aggregator_item')193 ->condition('iid', $iids, 'IN')194 ->execute();195 }196 }197}...
aggregator
Using AI Code Generation
1$aggregator = new \mageekguy\atoum\reports\aggregators\runner();2$aggregator->addWriter(new \mageekguy\atoum\writers\std\out());3$aggregator->addWriter(new \mageekguy\atoum\writers\file('path/to/file.txt'));4$runner->setAggregator($aggregator);5$score = new \mageekguy\atoum\score();6$score->addWriter(new \mageekguy\atoum\writers\std\out());7$score->addWriter(new \mageekguy\atoum\writers\file('path/to/file.txt'));8$runner->setScore($score);9$coverage = new \mageekguy\atoum\coverage\html();10$coverage->addWriter(new \mageekguy\atoum\writers\std\out());11$coverage->addWriter(new \mageekguy\atoum\writers\file('path/to/file.txt'));12$runner->setCoverage($coverage);13$locale = new \mageekguy\atoum\locale();14$locale->addWriter(new \mageekguy\atoum\writers\std\out());15$locale->addWriter(new \mageekguy\atoum\writers\file('path/to/file.txt'));16$runner->setLocale($locale);17$assertionManager = new \mageekguy\atoum\asserters\manager();18$assertionManager->addWriter(new \mageekguy\atoum\writers\std\out());19$assertionManager->addWriter(new \mageekguy\atoum\writers\file('path/to/file.txt'));20$runner->setAssertionManager($assertionManager);21$test = new \mageekguy\atoum\test();22$test->addWriter(new \mageekguy\atoum\writers\std\out());23$test->addWriter(new \mageekguy\atoum\writers\file('path/to/file.txt
aggregator
Using AI Code Generation
1require_once 'atoum/classes/aggregator.php';2require_once 'atoum/classes/aggregator.php';3require_once 'atoum/classes/aggregator.php';4require_once 'atoum/classes/aggregator.php';5require_once 'atoum/classes/aggregator.php';6require_once 'atoum/classes/aggregator.php';7require_once 'atoum/classes/aggregator.php';8require_once 'atoum/classes/aggregator.php';9require_once 'atoum/classes/aggregator.php';10require_once 'atoum/classes/aggregator.php';11require_once 'atoum/classes/aggregator.php';12require_once 'atoum/classes/aggregator.php';13require_once 'atoum/classes/aggregator.php';14require_once 'atoum/classes/aggregator.php';15require_once 'atoum/classes/aggregator.php';16require_once 'atoum/classes/aggregator.php';17require_once 'atoum/classes/aggregator.php';
aggregator
Using AI Code Generation
1namespace Atoum\Aggregator\Tests\Units;2use mageekguy\atoum;3{4 public function testAggregator()5 {6 ->given($this->newTestedInstance)7 ->object($this->testedInstance->add(1, 2))8 ->isEqualTo(3)9 ;10 }11}12namespace Atoum\Aggregator\Tests\Units;13use mageekguy\atoum;14{15 public function testAggregator()16 {17 ->given($this->newTestedInstance)18 ->object($this->testedInstance->add(1, 2))19 ->isEqualTo(3)20 ;21 }22}23namespace Atoum\Aggregator\Tests\Units;24use mageekguy\atoum;25{26 public function testAggregator()27 {28 ->given($this->newTestedInstance)29 ->object($this->testedInstance->add(1, 2))30 ->isEqualTo(3)31 ;32 }33}34namespace Atoum\Aggregator\Tests\Units;35use mageekguy\atoum;36{37 public function testAggregator()38 {39 ->given($this->newTestedInstance)40 ->object($this->testedInstance->add(1, 2))41 ->isEqualTo(3)42 ;43 }44}45namespace Atoum\Aggregator\Tests\Units;46use mageekguy\atoum;47{48 public function testAggregator()49 {50 ->given($this->newTestedInstance)51 ->object($this->testedInstance->add(1, 2))52 ->isEqualTo(3)53 ;54 }55}
aggregator
Using AI Code Generation
1$aggregator = new atoum\aggregator();2$aggregator->addDirectory('./tests');3$runner->setPhpPath('/usr/bin/php');4$runner->addTestsFromDirectory('./tests');5$script->addDefaultReport();6$runner->setBootstrapFile('bootstrap.php');7$runner->addDefaultReport();8$runner->run();9require_once 'vendor/autoload.php';10{11 "require": {12 }13}14{
aggregator
Using AI Code Generation
1$aggregator = new \mageekguy\atoum\reports\asynchronous\aggregator();2$coverage = new \mageekguy\atoum\reports\coverage\html();3$coverage->addWriter(new \mageekguy\atoum\writers\file('path/to/coverage.html'));4$coverage = new \mageekguy\atoum\reports\coverage\html();5$coverage->addWriter(new \mageekguy\atoum\writers\file('path/to/coverage.html'));6$coverage = new \mageekguy\atoum\reports\coverage\html();7$coverage->addWriter(new \mageekguy\atoum\writers\file('path/to/coverage.html'));8$coverage = new \mageekguy\atoum\reports\coverage\html();9$coverage->addWriter(new \mageekguy\atoum\writers\file('path/to/coverage.html'));10$coverage = new \mageekguy\atoum\reports\coverage\html();11$coverage->addWriter(new \mageekguy\atoum\writers\file('path/to/coverage.html'));12$coverage = new \mageekguy\atoum\reports\coverage\html();13$coverage->addWriter(new \mageekguy\atoum\writers\file('path/to/coverage.html'));14$coverage = new \mageekguy\atoum\reports\coverage\html();15$coverage->addWriter(new \mageekguy\atoum\writers\file('path/to/coverage.html'));16$coverage = new \mageekguy\atoum\reports\coverage\html();17$coverage->addWriter(new \mageekguy\atoum\writers\file('path/to/coverage.html'));
aggregator
Using AI Code Generation
1require_once 'atoum/aggregator.php';2require_once 'atoum/runner.php';3require_once 'atoum/report.php';4require_once 'atoum/test.php';5require_once 'atoum/asserter.php';6require_once 'atoum/exceptions.php';7require_once 'atoum/autoloader.php';8require_once 'atoum/adapter.php';9require_once 'atoum/mock.php';10require_once 'atoum/mocker.php';11require_once 'atoum/asserter.php';12require_once 'atoum/exceptions.php';13require_once 'atoum/autoloader.php';14require_once 'atoum/adapter.php';15require_once 'atoum/mock.php';16require_once 'atoum/mocker.php';17require_once 'atoum/asserter.php';18require_once 'atoum/exceptions.php';19require_once 'atoum/autoloader.php';20require_once 'atoum/adapter.php';21require_once 'atoum/mock.php';22require_once 'atoum/mocker.php';23require_once 'atoum/asserter.php';24require_once 'atoum/exceptions.php';25require_once 'atoum/autoloader.php';26require_once 'atoum/adapter.php';27require_once 'atoum/mock.php';28require_once 'atoum/mocker.php';29require_once 'atoum/asserter.php';30require_once 'atoum/exceptions.php';31require_once 'atoum/autoloader.php';32require_once 'atoum/adapter.php';33require_once 'atoum/mock.php';34require_once 'atoum/mocker.php';35require_once 'atoum/asserter.php';36require_once 'atoum/exceptions.php';37require_once 'atoum/autoloader.php';38require_once 'atoum/adapter.php';39require_once 'atoum/mock.php';40require_once 'atoum/mocker.php';41require_once 'atoum/asserter.php';42require_once 'atoum/exceptions.php';43require_once 'atoum/autoloader.php';44require_once 'atoum/adapter.php';45require_once 'atoum/mock.php';46require_once 'atoum/mocker.php';47require_once 'atoum/asserter.php';
aggregator
Using AI Code Generation
1use mageekguy\atoum\tests\units;2use \atoum\atoum\tests\units\example;3{4 public function testAdd()5 {6 ->if($example = new example())7 ->integer($example->add(1, 2))->isEqualTo(3)8 ->integer($example->add(2, 2))->isEqualTo(4)9 ->integer($example->add(3, 2))->isEqualTo(5)10 ;11 }12}13use mageekguy\atoum\tests\units;14use \atoum\atoum\tests\units\example;15{16 public function testSub()17 {18 ->if($example = new example())19 ->integer($example->sub(1, 2))->isEqualTo(-1)20 ->integer($example->sub(2, 2))->isEqualTo(0)21 ->integer($example->sub(3, 2))->isEqualTo(1)22 ;23 }24}25use mageekguy\atoum\tests\units;26use \atoum\atoum\tests\units\example;27{28 public function testMul()29 {30 ->if($example = new example())31 ->integer($example->mul(1, 2))->isEqualTo(2)32 ->integer($example->mul(2, 2))->isEqualTo(4)33 ->integer($example->mul(3, 2))->isEqualTo(6)34 ;35 }36}37use mageekguy\atoum\tests\units;38use \atoum\atoum\tests\units\example;39{40 public function testDiv()41 {42 ->if($example
aggregator
Using AI Code Generation
1require_once 'vendor/autoload.php';2require_once 'class.php';3class ClassToBeTested {4 public function __construct() {5 $this->aggregator = new Aggregator();6 }7 public function methodToBeTested() {8 $this->aggregator->methodToBeMocked();9 }10}11class ClassToBeTested extends atoum\test {12 public function testMethodToBeTested() {13 $this->mockGenerator->orphanize('__construct');14 $mock = new mock\Aggregator();15 $this->calling($mock)->methodToBeMocked = 'foo';16 $this->classToBeTested = new ClassToBeTested();17 $this->classToBeTested->methodToBeTested();18 }19}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.
Test now for FreeGet 100 minutes of automation test minutes FREE!!