public static function tearDownAfterClass() { if (defined('SKIPPING')) { return; } teardown(self::$db, DB_WIPE_FILE); }
public static function tearDownAfterClass() { if (defined('SKIPPING')) { return; } self::$db->execute(fix_schema(file_get_contents(DB_ALTERNATE_SCHEMA_WIPE_FILE))); teardown(self::$db, DB_WIPE_FILE); }
public static function tearDownAfterClass() { if (defined('SKIPPING')) { return; } teardown(self::$db, DB_EXTENDED_TEARDOWN_FILE); teardown(self::$db, DB_TEARDOWN_FILE); }
public static function tearDownAfterClass() { if (defined('SKIPPING')) { return; } teardown(self::$db, DB_TEARDOWN_FILE); self::$db->__destruct(); }
assert_equals(true, transient()->setup1); }); // TODO this is terrible should("count the number of tests", function () { assert_equals(4, Smoothie::instance()->tests); }); // TODO this is terrible should("count the number of assertions", function () { assert_equals(4, Smoothie::instance()->assertions); }); context("nested in a context", function () { setup(function () { transient()->setup2 = true; }); teardown(function () { $GLOBALS['I_RAN_TEARDOWN'] = true; }); should("have called its parent setup", function () { assert_equals(true, transient()->setup1); }); should("have called its own setup", function () { assert_equals(true, transient()->setup2); }); context("nested in a context", function () { setup(function () { transient()->setup3 = true; }); should("have called all three setups", function () { assert_equals(true, transient()->setup1); assert_equals(true, transient()->setup2); assert_equals(true, transient()->setup3);
/** * Write XML data to a file. * @param string $contents * @param string $xml_path where we write this */ function write_xml($contents, $xml_path) { if ($fh = @fopen($xml_path, 'w')) { fwrite($fh, $contents); fclose($fh); print 'config.xml file written at ' . $xml_path . PHP_EOL; } else { print 'There was a problem opening ' . $xml_path . ' for writing.' . PHP_EOL; print 'You can paste the following contents into ' . $xml_path . PHP_EOL; print 'and then run: php ./index.php --installmode=new' . PHP_EOL; print 'or navigate to your site via a browser and do a normal installation.' . PHP_EOL . PHP_EOL; print $contents; print PHP_EOL . PHP_EOL; teardown(); } }
<?php /* * How to use teardown */ namespace Preview\DSL\TDD; require_once __DIR__ . '/../ok.php'; suite("teardown", function () { teardown(function () { $this->usage = "run teardown each test case"; }); teardown(function () { $this->note = "teardown hooks are run in order"; }); });
<?php namespace Preview\DSL\Qunit; require_once __DIR__ . '/../ok.php'; suite("teardown"); teardown(function () { $this->usage = "this will function be called after each test case"; }); teardown(function () { $this->note_1 = "you can have multiple teardown"; }); teardown(function () { $this->note_2 = "teardown functions are run in order"; }); test("Run a test", function () { ok(true); }); test("Run a another test", function () { ok(true); }); teardown(function () { $this->note_3 = "It dosen't even matter where you put teardown function"; });