Remove product literal strings in "pht()", part 18
[phabricator.git] / src / infrastructure / storage / lisk / __tests__ / LiskIsolationTestCase.php
blob8ff5068505f417f1abf6fe63f93dbb790ba48c70
1 <?php
3 final class LiskIsolationTestCase extends PhabricatorTestCase {
5 public function testIsolatedWrites() {
6 $dao = new LiskIsolationTestDAO();
8 $this->assertEqual(null, $dao->getID(), pht('Expect no ID.'));
9 $this->assertEqual(null, $dao->getPHID(), pht('Expect no PHID.'));
11 $dao->save(); // Effects insert
13 $id = $dao->getID();
14 $phid = $dao->getPHID();
16 $this->assertTrue((bool)$id, pht('Expect ID generated.'));
17 $this->assertTrue((bool)$phid, pht('Expect PHID generated.'));
19 $dao->save(); // Effects update
21 $this->assertEqual($id, $dao->getID(), pht('Expect ID unchanged.'));
22 $this->assertEqual($phid, $dao->getPHID(), pht('Expect PHID unchanged.'));
25 public function testEphemeral() {
26 $dao = new LiskIsolationTestDAO();
27 $dao->save();
28 $dao->makeEphemeral();
30 $this->tryTestCases(
31 array(
32 $dao,
34 array(
35 false,
37 array($this, 'saveDAO'));
40 public function saveDAO($dao) {
41 $dao->save();
44 public function testIsolationContainment() {
45 $dao = new LiskIsolationTestDAO();
47 try {
48 $method = new ReflectionMethod($dao, 'establishLiveConnection');
49 $method->setAccessible(true);
50 $method->invoke($dao, 'r');
52 $this->assertFailure(
53 pht(
54 '%s did not throw an exception when instructed to '.
55 'explicitly connect to an external database.',
56 'LiskIsolationTestDAO'));
57 } catch (LiskIsolationTestDAOException $ex) {
58 // Expected, pass.
61 $this->assertTrue(true);
64 public function testMagicMethods() {
66 $dao = new LiskIsolationTestDAO();
68 $this->assertEqual(
69 null,
70 $dao->getName(),
71 pht('%s on empty object', 'getName()'));
73 $this->assertEqual(
74 $dao,
75 $dao->setName('x'),
76 pht('%s returns %s', 'setName()', '$this'));
78 $this->assertEqual(
79 'y',
80 $dao->setName('y')->getName(),
81 pht('%s has an effect', 'setName()'));
83 $ex = null;
84 try {
85 $dao->gxxName();
86 } catch (Exception $thrown) {
87 $ex = $thrown;
89 $this->assertTrue(
90 (bool)$ex,
91 pht('Typoing "%s" should throw.', 'get'));
93 $ex = null;
94 try {
95 $dao->sxxName('z');
96 } catch (Exception $thrown) {
97 $ex = $thrown;
99 $this->assertTrue(
100 (bool)$ex,
101 pht('Typoing "%s" should throw.', 'set'));
103 $ex = null;
104 try {
105 $dao->madeUpMethod();
106 } catch (Exception $thrown) {
107 $ex = $thrown;
109 $this->assertTrue(
110 (bool)$ex,
111 pht('Made up method should throw.'));