# Creating a functional tests Functional tests test your controllers. The core of these are the same as unit tests: * Create a subclass of `[api:SapphireTest]` in the `mysite/tests` or `(module)/tests` folder. * Define static $fixture_file to point to a database YAML file. * Create methods that start with "test" to create your tests. * Assertions are used to work out if a test passed or failed. The code of the tests is a little different. Instead of examining the behaviour of objects, we example the results of URLs. Here is an example from the subsites module: :::php class SubsiteAdminTest extends SapphireTest { private static $fixture_file = 'subsites/tests/SubsiteTest.yml'; /** * Return a session that has a user logged in as an administrator */ public function adminLoggedInSession() { return new Session(array( 'loggedInAs' => $this->idFromFixture('Member', 'admin') )); } /** * Test generation of the view */ public function testBasicView() { // Open the admin area logged in as admin $response1 = Director::test('admin/subsites/', null, $this->adminLoggedInSession()); // Confirm that this URL gets you the entire page, with the edit form loaded $response2 = Director::test('admin/subsites/show/1', null, $this->adminLoggedInSession()); $this->assertTrue(strpos($response2->getBody(), 'id="Root_Configuration"') !== false); $this->assertTrue(strpos($response2->getBody(), '
1), $this->adminLoggedInSession()); $this->assertTrue(strpos($response3->getBody(), 'id="Root_Configuration"') !== false); $this->assertTrue(strpos($response3->getBody(), '