Advertisement
Guest User

Untitled

a guest
May 15th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <?php
  2. use SilverStripe\Dev\SapphireTest;
  3. use SilverStripe\Control\HTTPResponse;
  4. use SilverStripe\Control\HTTPRequest;
  5. // use SilverStripe\Control\HTTPClient;
  6. // use DOMDocument;
  7.  
  8. class StyleTest extends SapphireTest
  9. {
  10. public function testCssPropertyExists()
  11. {
  12.  
  13. $this->get('/video-pages/');
  14. // Check if the request was successful        
  15. $this->assertEquals(200, $this->response->getStatusCode());
  16. // Get the content of the response        
  17. $content = $this->response->getBody();
  18. // Pass the response to the DOMDocument
  19. $dom = new DOMDocument();
  20. @$dom->loadHTML($response->getBody());
  21.  
  22. // Perform the XPath query as before
  23. $xpath = new DOMXPath($dom);
  24. $elements = $xpath->query('//h1[contains(@class,"custom-heading-title")]');
  25.  
  26. // Make the necessary assertions
  27. $this->assertTrue($elements->length > 0);
  28.  
  29. foreach ($elements as $element) {
  30. $styleAttribute = $element->getAttribute('style');
  31. $this->assertStringContainsString('color: red;', $styleAttribute);
  32. }
  33. }
  34. }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement