Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- mysite/tests/HomePageTest.yaml:
- HomePage:
- home:
- Title: Home Page 12
- Content: This is the content of home
- URLSegment: home
- -- mysite/tests/HomePageTest.php
- <?php
- class HomePageTest extends SapphireTest {
- static $fixture_file = 'HomePageTest.yml';
- private $someVar = "nothing";
- public function setUp() {
- parent::setUp();
- $this->someVar = "this is set in setUp";
- }
- /**
- * sample unit test with 3 assertions
- */
- public function testUnitHome() {
- $fixture = "home";
- $obj = $this->objFromFixture("HomePage", $fixture);
- $this->assertEquals("Home Page 12", $obj->getTitle());
- $this->assertEquals("this is set in setUp", $this->someVar);
- $this->assertTrue(stripos($obj->getField('Content'), 'This is the content of home') !== false);
- }
- /**
- * sample functional test
- */
- public function testFunctionalHome() {
- $response = Director::test('');
- $body = $response->getBody();
- $this->assertTrue(stripos($body, '<head>') !== false);
- }
- /**
- * functional test: see if js are there
- */
- public function testJsThere() {
- $response = Director::test('home/');
- $body = $response->getBody();
- echo "\n\n". $body ."\n\n";
- $jss = array(
- '<script src="themes/bootstrap/js/bootstrap-modal.js"></script>',
- );
- foreach ($jss as $js) {
- $this->assertTrue(stripos($body, $js) !== false);
- }
- }
- }
- ?>
- OUTPUT:
- ...
- Page not found
- ...
- 3 tests run: 3 passes, 0 failures, and 0 incomplete with 0 errors
- EXPECTED:
- This is the content of home
- instead of
- Page not found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement