FeedLanguageTest.php in Zircon Profile 8
File
core/modules/aggregator/src/Tests/FeedLanguageTest.php
View source
<?php
namespace Drupal\aggregator\Tests;
use Drupal\language\Entity\ConfigurableLanguage;
class FeedLanguageTest extends AggregatorTestBase {
public static $modules = array(
'language',
);
protected $langcodes = array();
protected function setUp() {
parent::setUp();
$this->langcodes = array(
ConfigurableLanguage::load('en'),
);
for ($i = 1; $i < 3; ++$i) {
$language = ConfigurableLanguage::create(array(
'id' => 'l' . $i,
'label' => $this
->randomString(),
));
$language
->save();
$this->langcodes[$i] = $language
->id();
}
}
public function testFeedLanguage() {
$admin_user = $this
->drupalCreateUser([
'administer languages',
'access administration pages',
'administer news feeds',
'access news feeds',
'create article content',
]);
$this
->drupalLogin($admin_user);
$edit['entity_types[aggregator_feed]'] = TRUE;
$edit['settings[aggregator_feed][aggregator_feed][settings][language][language_alterable]'] = TRUE;
$this
->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
$feeds = array();
$feeds[1] = $this
->createFeed(NULL, array(
'langcode[0][value]' => $this->langcodes[1],
));
$feeds[2] = $this
->createFeed(NULL, array(
'langcode[0][value]' => $this->langcodes[2],
));
$this
->assertEqual($feeds[1]
->language()
->getId(), $this->langcodes[1]);
$this
->assertEqual($feeds[2]
->language()
->getId(), $this->langcodes[2]);
$this
->createSampleNodes();
$this
->cronRun();
foreach ($feeds as $feed) {
$items = entity_load_multiple_by_properties('aggregator_item', array(
'fid' => $feed
->id(),
));
$this
->assertTrue(count($items) > 0, 'Feed items were created.');
foreach ($items as $item) {
$this
->assertEqual($item
->language()
->getId(), $feed
->language()
->getId());
}
}
}
}