├── README.md └── tests ├── bootstrap.php ├── path └── to │ └── class │ └── MyClassTest.php └── phpunit.xml.dist /README.md: -------------------------------------------------------------------------------- 1 | PHPUnit-skeleton-for-project 2 | ============================ 3 | 4 | Скелет файловой структуры и пример организации класса для тестирования с помощью PHPUnit 5 | Заточено под 1С-Битрикс, содержимое репозитория нужно ложить в папку local корня сайта. 6 | 7 | В бутстрап файле (tests/bootstrap.php) объявляется функция для инициализации ядра BitrixFramework - initBitrixCore() 8 | Эту функцию нужно вызывать в методе setUp() каждого тест-класса 9 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | getConnection(); 22 | $DB->db_Conn = $con->getResource(); 23 | 24 | // "authorizing" as admin 25 | $_SESSION["SESS_AUTH"]["USER_ID"] = 1; 26 | } 27 | -------------------------------------------------------------------------------- /tests/path/to/class/MyClassTest.php: -------------------------------------------------------------------------------- 1 | classOB = new MyClass(); 11 | } 12 | 13 | public function testMyTest() 14 | { 15 | $this->assertTrue(true); 16 | } 17 | 18 | public function testIfModulesInstalled() 19 | { 20 | $this->assertTrue(Bitrix\Main\ModuleManager::IsModuleInstalled("iblock"), 'Модуль "iblock" не установлен.'); 21 | $this->assertTrue(Bitrix\Main\ModuleManager::IsModuleInstalled("catalog"), 'Модуль "catalog" не установлен.'); 22 | $this->assertTrue(Bitrix\Main\ModuleManager::IsModuleInstalled("sale"), 'Модуль "sale" не установлен.'); 23 | } 24 | 25 | public function tearDown() 26 | { 27 | unset($this->classOB); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | ./ 7 | 8 | 9 | --------------------------------------------------------------------------------