Exemplo n.º 1
0
 /**
  * Stash the current changes, only if there have been uncommitted changes
  */
 protected function stash()
 {
     if ($this->getGit()->hasChanges()) {
         // If we have changes, we stash them to restore state when we're done
         $os = new OperationState();
         $os->setExecute(array($this->getGit(), 'run'), array('stash'));
         $os->setUndo(array($this, 'unstash'), OperationState::NO_ARGUMENT);
         $this->getOsm()->add($os);
         // TODO: log
         $this->getOsm()->execute($os);
         $this->setStashStack($this->getStashStack() + 1);
     }
 }
 /**
  * @covers Sadekbaroudi\OperationState\OperationState::getKey
  */
 public function testKeyPersistence()
 {
     $obj = new OperationState();
     $key1 = $obj->getKey();
     $key2 = $obj->getKey();
     $this->assertEquals($key1, $key2, '$key1 should equal $key2, since they come from the same object');
     $this->assertTrue(is_string($key1), '$key1 is not a string');
     $this->assertTrue(is_string($key2), '$key2 is not a string');
     $obj2 = new OperationState();
     $key3 = $obj2->getKey();
     $this->assertNotEquals($key1, $key3, '$key1 should not equal $key3, since they come from different objects');
 }