Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use SilverStripe\Dev\SapphireTest;
- use SilverStripe\Control\HTTPResponse;
- use SilverStripe\Control\HTTPRequest;
- // use SilverStripe\Control\HTTPClient;
- // use DOMDocument;
- class StyleTest extends SapphireTest
- {
- public function testCssPropertyExists()
- {
- $this->get('/video-pages/');
- // Check if the request was successful
- $this->assertEquals(200, $this->response->getStatusCode());
- // Get the content of the response
- $content = $this->response->getBody();
- // Pass the response to the DOMDocument
- $dom = new DOMDocument();
- @$dom->loadHTML($response->getBody());
- // Perform the XPath query as before
- $xpath = new DOMXPath($dom);
- $elements = $xpath->query('//h1[contains(@class,"custom-heading-title")]');
- // Make the necessary assertions
- $this->assertTrue($elements->length > 0);
- foreach ($elements as $element) {
- $styleAttribute = $element->getAttribute('style');
- $this->assertStringContainsString('color: red;', $styleAttribute);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement