[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class LiskIsolationTestCase extends PhabricatorTestCase { 4 5 public function testIsolatedWrites() { 6 $dao = new LiskIsolationTestDAO(); 7 8 $this->assertEqual(null, $dao->getID(), 'Expect no ID.'); 9 $this->assertEqual(null, $dao->getPHID(), 'Expect no PHID.'); 10 11 $dao->save(); // Effects insert 12 13 $id = $dao->getID(); 14 $phid = $dao->getPHID(); 15 16 $this->assertTrue((bool)$id, 'Expect ID generated.'); 17 $this->assertTrue((bool)$phid, 'Expect PHID generated.'); 18 19 $dao->save(); // Effects update 20 21 $this->assertEqual($id, $dao->getID(), 'Expect ID unchanged.'); 22 $this->assertEqual($phid, $dao->getPHID(), 'Expect PHID unchanged.'); 23 } 24 25 public function testEphemeral() { 26 $dao = new LiskIsolationTestDAO(); 27 $dao->save(); 28 $dao->makeEphemeral(); 29 30 $this->tryTestCases( 31 array( 32 $dao, 33 ), 34 array( 35 false, 36 ), 37 array($this, 'saveDAO')); 38 } 39 40 public function saveDAO($dao) { 41 $dao->save(); 42 } 43 44 public function testIsolationContainment() { 45 $dao = new LiskIsolationTestDAO(); 46 47 try { 48 $dao->establishLiveConnection('r'); 49 50 $this->assertFailure( 51 'LiskIsolationTestDAO did not throw an exception when instructed to '. 52 'explicitly connect to an external database.'); 53 } catch (LiskIsolationTestDAOException $ex) { 54 // Expected, pass. 55 } 56 57 $this->assertTrue(true); 58 } 59 60 public function testMagicMethods() { 61 62 $dao = new LiskIsolationTestDAO(); 63 64 $this->assertEqual( 65 null, 66 $dao->getName(), 67 'getName() on empty object'); 68 69 $this->assertEqual( 70 $dao, 71 $dao->setName('x'), 72 'setName() returns $this'); 73 74 $this->assertEqual( 75 'y', 76 $dao->setName('y')->getName(), 77 'setName() has an effect'); 78 79 $ex = null; 80 try { 81 $dao->gxxName(); 82 } catch (Exception $thrown) { 83 $ex = $thrown; 84 } 85 $this->assertTrue( 86 (bool)$ex, 87 'Typoing "get" should throw.'); 88 89 $ex = null; 90 try { 91 $dao->sxxName('z'); 92 } catch (Exception $thrown) { 93 $ex = $thrown; 94 } 95 $this->assertTrue( 96 (bool)$ex, 97 'Typoing "set" should throw.'); 98 99 $ex = null; 100 try { 101 $dao->madeUpMethod(); 102 } catch (Exception $thrown) { 103 $ex = $thrown; 104 } 105 $this->assertTrue( 106 (bool)$ex, 107 'Made up method should throw.'); 108 } 109 110 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |