{"action":"created","comment":{"url":"https://api.github.com/repos/civicrm/civihr/pulls/comments/69030806","id":69030806,"diff_hunk":"@@ -1,45 +1,27 @@\n <?php\n-/*\n-+--------------------------------------------------------------------+\n-| CiviHR version 1.4                                                 |\n-+--------------------------------------------------------------------+\n-| Copyright CiviCRM LLC (c) 2004-2014                                |\n-+--------------------------------------------------------------------+\n-| This file is a part of CiviCRM.                                    |\n-|                                                                    |\n-| CiviCRM is free software; you can copy, modify, and distribute it  |\n-| under the terms of the GNU Affero General Public License           |\n-| Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |\n-|                                                                    |\n-| CiviCRM is distributed in the hope that it will be useful, but     |\n-| WITHOUT ANY WARRANTY; without even the implied warranty of         |\n-| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |\n-| See the GNU Affero General Public License for more details.        |\n-|                                                                    |\n-| You should have received a copy of the GNU Affero General Public   |\n-| License and the CiviCRM Licensing Exception along                  |\n-| with this program; if not, contact CiviCRM LLC                     |\n-| at info[AT]civicrm[DOT]org. If you have questions about the        |\n-| GNU Affero General Public License or the licensing of CiviCRM,     |\n-| see the CiviCRM license FAQ at http://civicrm.org/licensing        |\n-+--------------------------------------------------------------------+\n-*/\n-\n-require_once 'CiviTest/CiviUnitTestCase.php';\n+\n+use Civi\\Test\\HeadlessInterface;\n+use Civi\\Test\\TransactionalInterface;\n \n /**\n- * Class api_v3_HRVacancyStageTest\n+ * Class api_v3_HRVacancyTest\n+ *\n+ * @group headless\n  */\n-class api_v3_HRVacancyStageTest extends CiviUnitTestCase {\n+class api_v3_HRVacancyStageTest extends CiviUnitTestCase implements HeadlessInterface , TransactionalInterface {\n   protected $_apiversion = 3;\n \n+  public function setUpHeadless() {\n+    return \\Civi\\Test::headless()\n+      ->installMe(__DIR__)\n+      ->apply();\n+  }\n+\n   function setUp() {\n     $this->_entity = 'HRVacancy';\n \n     parent::setUp();\n     $this->_apiversion = 3;\n-    $this->tablesToTruncate = array( 'civicrm_hrvacancy', 'civicrm_hrvacancy_stage' );\n-    $this->quickCleanup($this->tablesToTruncate);\n     $this->createLoggedInUser();\n     $session = CRM_Core_Session::singleton();\n     $this->_loggedInUser = $session->get('userID');","path":"hrrecruitment/tests/phpunit/api/v3/HRVacancyStageTest.php","position":58,"original_position":58,"commit_id":"69312c2e779bb11b0e7ad6c4d4c642919be36747","original_commit_id":"2c8bce962f54d7f36873efbded4f9fd0bfd02cd6","user":{"login":"omarabuhussein","id":6275540,"avatar_url":"https://avatars.githubusercontent.com/u/6275540?v=3","gravatar_id":"","url":"https://api.github.com/users/omarabuhussein","html_url":"https://github.com/omarabuhussein","followers_url":"https://api.github.com/users/omarabuhussein/followers","following_url":"https://api.github.com/users/omarabuhussein/following{/other_user}","gists_url":"https://api.github.com/users/omarabuhussein/gists{/gist_id}","starred_url":"https://api.github.com/users/omarabuhussein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omarabuhussein/subscriptions","organizations_url":"https://api.github.com/users/omarabuhussein/orgs","repos_url":"https://api.github.com/users/omarabuhussein/repos","events_url":"https://api.github.com/users/omarabuhussein/events{/privacy}","received_events_url":"https://api.github.com/users/omarabuhussein/received_events","type":"User","site_admin":false},"body":"I've changed that to :\r\n\r\n```php\r\n    //Create Vacancy\r\n    $vacancyParams = array(\r\n      'position' => 'Test',\r\n      'is_template' => '0',\r\n      'start_date' => '2014-05-08 00:00:00',\r\n      'end_date' => '2014-05-27 00:00:00',\r\n      'status_id' => 'Draft',\r\n      'created_id' => 1,\r\n    );\r\n```\r\n\r\nsince the default organization is always there and its ID is 1","created_at":"2016-06-29T21:23:38Z","updated_at":"2016-06-29T21:23:38Z","html_url":"https://github.com/civicrm/civihr/pull/990#discussion_r69030806","pull_request_url":"https://api.github.com/repos/civicrm/civihr/pulls/990","_links":{"self":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/comments/69030806"},"html":{"href":"https://github.com/civicrm/civihr/pull/990#discussion_r69030806"},"pull_request":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/990"}}},"pull_request":{"url":"https://api.github.com/repos/civicrm/civihr/pulls/990","id":75485826,"html_url":"https://github.com/civicrm/civihr/pull/990","diff_url":"https://github.com/civicrm/civihr/pull/990.diff","patch_url":"https://github.com/civicrm/civihr/pull/990.patch","issue_url":"https://api.github.com/repos/civicrm/civihr/issues/990","number":990,"state":"open","locked":false,"title":"PCHR-1201: migrating tests to 4.7","user":{"login":"omarabuhussein","id":6275540,"avatar_url":"https://avatars.githubusercontent.com/u/6275540?v=3","gravatar_id":"","url":"https://api.github.com/users/omarabuhussein","html_url":"https://github.com/omarabuhussein","followers_url":"https://api.github.com/users/omarabuhussein/followers","following_url":"https://api.github.com/users/omarabuhussein/following{/other_user}","gists_url":"https://api.github.com/users/omarabuhussein/gists{/gist_id}","starred_url":"https://api.github.com/users/omarabuhussein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omarabuhussein/subscriptions","organizations_url":"https://api.github.com/users/omarabuhussein/orgs","repos_url":"https://api.github.com/users/omarabuhussein/repos","events_url":"https://api.github.com/users/omarabuhussein/events{/privacy}","received_events_url":"https://api.github.com/users/omarabuhussein/received_events","type":"User","site_admin":false},"body":"## Problem\r\ntests in civicrm 4.5 are slow ... they initialize a full instance of civicrm which is so heavy and cause the slowness ... but In civicrm 4.7 stuff changed and there is a  headless class that can be implemented in the tests classes to run the tests with minimal civicrm initialization . But since civihr 1.5 was based on civicrm 4.5 and now we have civihr 1.7 which is based on civicrm 4.7 we wanted to modify the tests to adhere to this headless way in testing.\r\n\r\n## Insights\r\n\r\nIn civihr , only the following extensions have tests :\r\n\r\nExtensions with unit tests : \r\n- hrreport\r\n- hrvisa\r\n- hrcaseutils \r\n- apprisals \r\n- hrjobcontract \r\n- hrrecuitment\r\n\r\nExtensions with web tests ( selenium tests ) :\r\n\r\n- hrbank\r\n- hrcarrer\r\n- hrstaffdir\r\n- hrequal\r\n- hremerg\r\n- hrident\r\n- hrcase\r\n- hrmed\r\n\r\nalso note that contactaccessrights had some dummy tests so I removed them.\r\n\r\n## Solution\r\n\r\n- I changed the test classes to implement both HeadlessInterface and TransactionalInterface and enabled the necessary extensions in the headless method .\r\n\r\n- In rare cases I changed the test class to extend PHPUnit_Framework_TestCase  instead of CiviUnitTestCase in case CiviUnitTestCase are not used in the tests (but we should get rid of CiviUnitTestCase once we implement our solution to share common test methods between extensions  since CiviUnitTestCase come with performance cost).\r\n\r\n- Since I implemented the TransactionalInterface which will rollback operations on database automatically , as will HeadlessInterface which will initialize the database I had to implement both setUP and tearDown methods with empty body in case the test class extends CiviUnitTestCase to avoid implementing these method in the parent class (CiviUnitTestCase) which will cause some problems specially with tearDown method.\r\n\r\n","created_at":"2016-06-28T14:21:38Z","updated_at":"2016-06-29T21:23:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6e7eff9bf83e214e0bf0814ff82366a9ca0b1c82","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/civicrm/civihr/pulls/990/commits","review_comments_url":"https://api.github.com/repos/civicrm/civihr/pulls/990/comments","review_comment_url":"https://api.github.com/repos/civicrm/civihr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/civicrm/civihr/issues/990/comments","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/69312c2e779bb11b0e7ad6c4d4c642919be36747","head":{"label":"civicrm:PCHR-1201-migrating-tests-4.7","ref":"PCHR-1201-migrating-tests-4.7","sha":"69312c2e779bb11b0e7ad6c4d4c642919be36747","user":{"login":"civicrm","id":136373,"avatar_url":"https://avatars.githubusercontent.com/u/136373?v=3","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"repo":{"id":10086903,"name":"civihr","full_name":"civicrm/civihr","owner":{"login":"civicrm","id":136373,"avatar_url":"https://avatars.githubusercontent.com/u/136373?v=3","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/civicrm/civihr","description":"CiviHR","fork":false,"url":"https://api.github.com/repos/civicrm/civihr","forks_url":"https://api.github.com/repos/civicrm/civihr/forks","keys_url":"https://api.github.com/repos/civicrm/civihr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/civicrm/civihr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/civicrm/civihr/teams","hooks_url":"https://api.github.com/repos/civicrm/civihr/hooks","issue_events_url":"https://api.github.com/repos/civicrm/civihr/issues/events{/number}","events_url":"https://api.github.com/repos/civicrm/civihr/events","assignees_url":"https://api.github.com/repos/civicrm/civihr/assignees{/user}","branches_url":"https://api.github.com/repos/civicrm/civihr/branches{/branch}","tags_url":"https://api.github.com/repos/civicrm/civihr/tags","blobs_url":"https://api.github.com/repos/civicrm/civihr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/civicrm/civihr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/civicrm/civihr/git/refs{/sha}","trees_url":"https://api.github.com/repos/civicrm/civihr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/{sha}","languages_url":"https://api.github.com/repos/civicrm/civihr/languages","stargazers_url":"https://api.github.com/repos/civicrm/civihr/stargazers","contributors_url":"https://api.github.com/repos/civicrm/civihr/contributors","subscribers_url":"https://api.github.com/repos/civicrm/civihr/subscribers","subscription_url":"https://api.github.com/repos/civicrm/civihr/subscription","commits_url":"https://api.github.com/repos/civicrm/civihr/commits{/sha}","git_commits_url":"https://api.github.com/repos/civicrm/civihr/git/commits{/sha}","comments_url":"https://api.github.com/repos/civicrm/civihr/comments{/number}","issue_comment_url":"https://api.github.com/repos/civicrm/civihr/issues/comments{/number}","contents_url":"https://api.github.com/repos/civicrm/civihr/contents/{+path}","compare_url":"https://api.github.com/repos/civicrm/civihr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/civicrm/civihr/merges","archive_url":"https://api.github.com/repos/civicrm/civihr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/civicrm/civihr/downloads","issues_url":"https://api.github.com/repos/civicrm/civihr/issues{/number}","pulls_url":"https://api.github.com/repos/civicrm/civihr/pulls{/number}","milestones_url":"https://api.github.com/repos/civicrm/civihr/milestones{/number}","notifications_url":"https://api.github.com/repos/civicrm/civihr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/civicrm/civihr/labels{/name}","releases_url":"https://api.github.com/repos/civicrm/civihr/releases{/id}","deployments_url":"https://api.github.com/repos/civicrm/civihr/deployments","created_at":"2013-05-15T20:06:06Z","updated_at":"2016-06-29T20:52:22Z","pushed_at":"2016-06-29T19:08:24Z","git_url":"git://github.com/civicrm/civihr.git","ssh_url":"git@github.com:civicrm/civihr.git","clone_url":"https://github.com/civicrm/civihr.git","svn_url":"https://github.com/civicrm/civihr","homepage":null,"size":21998,"stargazers_count":4,"watchers_count":4,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":6,"forks":22,"open_issues":6,"watchers":4,"default_branch":"develop"}},"base":{"label":"civicrm:PCHR-863-migrate-to-4.7","ref":"PCHR-863-migrate-to-4.7","sha":"317ecb99ad36b29ef0b41fd61bcfbb323d2133ee","user":{"login":"civicrm","id":136373,"avatar_url":"https://avatars.githubusercontent.com/u/136373?v=3","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"repo":{"id":10086903,"name":"civihr","full_name":"civicrm/civihr","owner":{"login":"civicrm","id":136373,"avatar_url":"https://avatars.githubusercontent.com/u/136373?v=3","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/civicrm/civihr","description":"CiviHR","fork":false,"url":"https://api.github.com/repos/civicrm/civihr","forks_url":"https://api.github.com/repos/civicrm/civihr/forks","keys_url":"https://api.github.com/repos/civicrm/civihr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/civicrm/civihr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/civicrm/civihr/teams","hooks_url":"https://api.github.com/repos/civicrm/civihr/hooks","issue_events_url":"https://api.github.com/repos/civicrm/civihr/issues/events{/number}","events_url":"https://api.github.com/repos/civicrm/civihr/events","assignees_url":"https://api.github.com/repos/civicrm/civihr/assignees{/user}","branches_url":"https://api.github.com/repos/civicrm/civihr/branches{/branch}","tags_url":"https://api.github.com/repos/civicrm/civihr/tags","blobs_url":"https://api.github.com/repos/civicrm/civihr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/civicrm/civihr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/civicrm/civihr/git/refs{/sha}","trees_url":"https://api.github.com/repos/civicrm/civihr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/{sha}","languages_url":"https://api.github.com/repos/civicrm/civihr/languages","stargazers_url":"https://api.github.com/repos/civicrm/civihr/stargazers","contributors_url":"https://api.github.com/repos/civicrm/civihr/contributors","subscribers_url":"https://api.github.com/repos/civicrm/civihr/subscribers","subscription_url":"https://api.github.com/repos/civicrm/civihr/subscription","commits_url":"https://api.github.com/repos/civicrm/civihr/commits{/sha}","git_commits_url":"https://api.github.com/repos/civicrm/civihr/git/commits{/sha}","comments_url":"https://api.github.com/repos/civicrm/civihr/comments{/number}","issue_comment_url":"https://api.github.com/repos/civicrm/civihr/issues/comments{/number}","contents_url":"https://api.github.com/repos/civicrm/civihr/contents/{+path}","compare_url":"https://api.github.com/repos/civicrm/civihr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/civicrm/civihr/merges","archive_url":"https://api.github.com/repos/civicrm/civihr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/civicrm/civihr/downloads","issues_url":"https://api.github.com/repos/civicrm/civihr/issues{/number}","pulls_url":"https://api.github.com/repos/civicrm/civihr/pulls{/number}","milestones_url":"https://api.github.com/repos/civicrm/civihr/milestones{/number}","notifications_url":"https://api.github.com/repos/civicrm/civihr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/civicrm/civihr/labels{/name}","releases_url":"https://api.github.com/repos/civicrm/civihr/releases{/id}","deployments_url":"https://api.github.com/repos/civicrm/civihr/deployments","created_at":"2013-05-15T20:06:06Z","updated_at":"2016-06-29T20:52:22Z","pushed_at":"2016-06-29T19:08:24Z","git_url":"git://github.com/civicrm/civihr.git","ssh_url":"git@github.com:civicrm/civihr.git","clone_url":"https://github.com/civicrm/civihr.git","svn_url":"https://github.com/civicrm/civihr","homepage":null,"size":21998,"stargazers_count":4,"watchers_count":4,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":6,"forks":22,"open_issues":6,"watchers":4,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/990"},"html":{"href":"https://github.com/civicrm/civihr/pull/990"},"issue":{"href":"https://api.github.com/repos/civicrm/civihr/issues/990"},"comments":{"href":"https://api.github.com/repos/civicrm/civihr/issues/990/comments"},"review_comments":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/990/comments"},"review_comment":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/990/commits"},"statuses":{"href":"https://api.github.com/repos/civicrm/civihr/statuses/69312c2e779bb11b0e7ad6c4d4c642919be36747"}}}}
{"actor":{"display_login":"omarabuhussein"}}