public function testShouldCopyToUser() { //THEN $this->_oIssueSetMock->expects($this->once())->method('copyToUser')->with($this->equalTo($this->_oUser)); //WHEN $this->_oApplication->copyToUser($this->_oUser); $this->_oApplication->refresh(); //THEN $this->assertEquals(2, $this->_oApplication->client, 'Client id should change'); $oGivenDataSet = $this->getConnection()->createQueryTable('application', 'SELECT id, client FROM application ORDER BY id'); $oExpectedDataSet = $this->createFlatXMLDataSet(dirname(__FILE__) . '/_dataset/copy.xml')->getTable('application'); $this->assertTablesEqual($oExpectedDataSet, $oGivenDataSet); }
public function testShouldNotMoveToSameUserClient() { //GIVEN //Get the user with the same client id $oUser = AM_Model_Db_Table_Abstract::factory('user')->findOneBy(array('id' => 3)); //THEN $this->_oIssueSetMock->expects($this->never())->method('moveToUser'); //WHEN $this->_oApplication->moveToUser($oUser); $this->_oApplication->refresh(); //THEN $this->assertEquals(1, $this->_oApplication->client, 'Client id should not change'); $oGivenDataSet = $this->getConnection()->createQueryTable('application', 'SELECT id, client FROM application ORDER BY id'); $oExpectedDataSet = $this->createFlatXMLDataSet(dirname(__FILE__) . '/_dataset/not_move.xml')->getTable('application'); $this->assertTablesEqual($oExpectedDataSet, $oGivenDataSet); }
public function setUp() { parent::setUp(); $revisionData = array("id" => 1, "title" => "test_revision", "state" => 1, "issue" => 1, "user" => 1); $this->revision = new AM_Model_Db_Revision(); $this->revision->setFromArray($revisionData); $this->revision->save(); $appData = array("id" => 1, "title" => "test_app1", "client" => 1); $app = new AM_Model_Db_Application(); $app->setFromArray($appData); $app->save(); $issueData = array("id" => 1, "title" => "test_issue1", "application" => 1, "user" => 1); $issue = new AM_Model_Db_Issue(); $issue->setFromArray($issueData); $issue->save(); $this->revision->setApplication($app); $this->revision->setIssue($issue); }