View source
<?php
namespace Drupal\Tests\eva\Functional;
class EvaTest extends EvaTestBase {
public function testEvaOnPage() {
$assert = $this
->assertSession();
$this
->drupalGet('/node/' . $this->nids['just_eva']);
$assert
->statusCodeEquals(200);
$this
->assertEquals($this->articleCount, \count($this
->xpath('//div[contains(@class, "view-eva")]//div[contains(@class, "views-row")]')), sprintf('Found %d articles in Eva.', $this->articleCount));
}
public function test2873385() {
$assert = $this
->assertSession();
$this
->drupalGet('/node/' . $this->nids['pages'][0]);
$assert
->statusCodeEquals(200);
$this
->drupalGet('/node/' . $this->nids['pages'][1]);
$assert
->statusCodeEquals(200);
$this
->drupalGet('/2873385');
$assert
->statusCodeEquals(200);
$evas = $this
->xpath('//div[contains(@class, "view-eva")]');
$all_links = [];
foreach ($evas as $x) {
$links = $x
->findAll('xpath', '//a');
$these_links = [];
foreach ($links as $l) {
$these_links[] = $l
->getText();
}
$all_links[] = implode('-', $these_links);
}
$this
->assertGreaterThan(1, \count(\array_unique($all_links)), 'Found more than one unique Eva.');
}
public function test3059233() {
$assert = $this
->assertSession();
$this
->drupalGet('/node/' . $this->nids['just_eva']);
$assert
->statusCodeEquals(200);
$this
->assertEquals($this->articleCount, \count($this
->xpath('//div[contains(@class, "view-eva")]//div[contains(@class, "views-row")]')), sprintf('Found %d articles in Eva.', $this->articleCount));
$orig = \Drupal::service('entity_type.manager')
->getStorage('view')
->load('articles');
$new = $orig
->createDuplicate();
$new
->set('id', 'articles_2');
$display = $new
->get('display');
$display['entity_view_1']['display_options']['bundles'] = [
'another_eva',
];
$new
->set('display', $display);
$new
->save();
$node = $this
->createNode([
'title' => 'Test Eva 2',
'type' => 'another_eva',
]);
$this->nids['new_page'] = $node
->id();
$this
->drupalGet('/node/' . $this->nids['new_page']);
$this
->assertEquals($this->articleCount, \count($this
->xpath('//div[contains(@class, "view-eva")]//div[contains(@class, "views-row")]')), sprintf('Found %d articles in Eva.', $this->articleCount));
$new
->delete();
$this
->drupalGet('/node/' . $this->nids['new_page']);
$this
->assertEquals(0, \count($this
->xpath('//div[contains(@class, "view-eva")]//div[contains(@class, "views-row")]')), sprintf('Found %d articles in Eva.', $this->articleCount));
}
}