Issues (35)

tests/Elements/ElementTestimonialsTest.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Dynamic\Elements\Tests\Elements;
4
5
use Dynamic\Elements\Elements\ElementTestimonials;
6
use Dynamic\Elements\Elements\TestimonialsElement;
0 ignored issues
show
The type Dynamic\Elements\Elements\TestimonialsElement was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use SilverStripe\Dev\SapphireTest;
8
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
9
use SilverStripe\Forms\NumericField;
10
use SilverStripe\ORM\DataList;
11
12
/**
13
 * Class ElementTestimonialsTest
14
 * @package Dynamic\Elements\Tests\Elements
15
 */
16
class ElementTestimonialsTest extends SapphireTest
17
{
18
    /**
19
     * @var string
20
     */
21
    protected static $fixture_file = '../fixtures.yml';
22
23
    /**
24
     *
25
     */
26
    public function testGetSummary()
27
    {
28
        $element = $this->objFromFixture(ElementTestimonials::class, 'one');
29
        $this->assertEquals('4 testimonials', $element->getSummary());
30
    }
31
32
    /**
33
     *
34
     */
35
    public function testGetType()
36
    {
37
        $element = $this->objFromFixture(ElementTestimonials::class, 'one');
38
        $this->assertEquals('Testimonials', $element->getType());
39
    }
40
41
    /**
42
     *
43
     */
44
    public function testGetCMSFields()
45
    {
46
        $element = $this->objFromFixture(ElementTestimonials::class, 'one');
47
        $fields = $element->getCMSFields();
48
        $this->assertInstanceOf(HTMLEditorField::class, $fields->dataFieldByName('Content'));
49
        $this->assertInstanceOf(NumericField::class, $fields->dataFieldByName('Limit'));
50
    }
51
52
    /**
53
     *
54
     */
55
    public function testGetTestimonialsList()
56
    {
57
        $element = $this->objFromFixture(ElementTestimonials::class, 'one');
58
        $this->assertInstanceOf(DataList::class, $element->getTestimonialsList());
59
60
        $elementTwo = $this->objFromFixture(ElementTestimonials::class, 'two');
61
        $this->assertInstanceOf(DataList::class, $elementTwo->getTestimonialsList());
62
63
        $elementThree = $this->objFromFixture(ElementTestimonials::class, 'three');
64
        $this->assertInstanceOf(DataList::class, $elementThree->getTestimonialsList());
65
66
        $setOne = $element->getTestimonialsList();
67
        $setTwo = $elementTwo->getTestimonialsList();
68
        $setThree = $elementThree->getTestimonialsList();
69
70
        $this->assertEquals(4, $setOne->count());
71
        $this->assertEquals(1, $setTwo->count());
72
        $this->assertEquals(3, $setThree->count());
73
    }
74
}
75