Skip to content

Commit a32fb34

Browse files
authored
Merge pull request #193 from bitrix24/dev
Build 1.4.0 release
2 parents bf1cb0c + 728153d commit a32fb34

File tree

245 files changed

+13184
-3459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+13184
-3459
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ composer.lock
77
tools/.env.local
88
tools/logs
99
tests/ApplicationBridge/auth.json
10+
tests/ApplicationBridge/*.log
1011
/examples/*.log
1112
/examples/**/*.log
1213
/examples/**/*/*.log
1314
docs/api/var
14-
/var
15+
/var/*
1516
*.private.env.*
1617
.env.local
1718
*.local
1819
/.php-cs-fixer.cache
20+
log.txt

.junie/guidelines.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Bitrix24 PHP SDK Development Guidelines
2+
3+
This document provides essential information for developers working on the Bitrix24 PHP SDK project.
4+
5+
## Build and Configuration Instructions
6+
7+
### Environment Setup
8+
9+
The project uses Docker for development and testing. The Docker environment is defined in `docker-compose.yaml` and `docker/php-cli/Dockerfile`.
10+
11+
1. **Docker Setup**:
12+
- The project uses PHP 8.3 CLI with Alpine Linux
13+
- Required PHP extensions: bcmath, intl, excimer
14+
- Composer is pre-installed in the Docker image
15+
16+
2. **Getting Started**:
17+
```bash
18+
# Clone the repository
19+
git clone https://github.com/bitrix24/b24phpsdk.git
20+
cd b24phpsdk
21+
22+
# Build the Docker image and install dependencies
23+
docker-compose build
24+
docker-compose run --rm php-cli composer install
25+
```
26+
27+
## Testing Information
28+
29+
### Test Structure
30+
31+
Tests are organized in the `tests` directory with the following structure:
32+
- `Unit/`: Unit tests that don't require external services
33+
- `Integration/`: Integration tests that interact with the Bitrix24 API
34+
- Further subdivided by API scope (Telephony, IM, User, etc.)
35+
- `Application/`: Tests for the Application component
36+
- `ApplicationBridge/`: Tests for application integration
37+
- `Builders/`: Test builders/factories
38+
- `CustomAssertions/`: Custom PHPUnit assertions
39+
40+
### Running Tests
41+
42+
Tests can be run using Make targets or directly with PHPUnit:
43+
44+
```bash
45+
# Run all unit tests
46+
make test-unit
47+
48+
# Run integration tests for a specific API scope
49+
make test-integration-scope-telephony
50+
make test-integration-scope-user
51+
# etc.
52+
53+
# Run a specific test file
54+
docker-compose run --rm php-cli vendor/bin/phpunit path/to/TestFile.php
55+
```
56+
57+
### Environment Configuration for Tests
58+
59+
1. **Environment Variables**:
60+
- Tests use environment variables defined in `tests/.env`
61+
- For integration tests, create a `tests/.env.local` file with your Bitrix24 webhook URL:
62+
```
63+
BITRIX24_WEBHOOK=https://your-portal.bitrix24.ru/rest/1/your-webhook-token/
64+
```
65+
66+
2. **Test Bootstrap**:
67+
- Tests are bootstrapped by `tests/bootstrap.php`
68+
- This file loads the autoloader and environment variables
69+
70+
### Creating New Tests
71+
72+
1. **Unit Tests**:
73+
- Create a new test class in the appropriate subdirectory of `tests/Unit/`
74+
- Extend `PHPUnit\Framework\TestCase`
75+
- Use the `#[\PHPUnit\Framework\Attributes\CoversClass]` attribute to specify which class is being tested
76+
- Follow the naming convention: `ClassNameTest.php`
77+
78+
2. **Integration Tests**:
79+
- Create a new test class in the appropriate subdirectory of `tests/Integration/`
80+
- Follow the same conventions as unit tests
81+
- Ensure you have the necessary environment variables set in `.env.local`
82+
83+
### Example Test
84+
85+
Here's a simple example of a unit test:
86+
87+
```php
88+
<?php
89+
90+
declare(strict_types=1);
91+
92+
namespace Bitrix24\SDK\Tests\Unit\Utility;
93+
94+
use Bitrix24\SDK\Utility\StringUtility;
95+
use PHPUnit\Framework\TestCase;
96+
97+
#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Utility\StringUtility::class)]
98+
class StringUtilityTest extends TestCase
99+
{
100+
public function testReverse(): void
101+
{
102+
$this->assertEquals('olleh', StringUtility::reverse('hello'));
103+
}
104+
105+
public function testIsPalindrome(): void
106+
{
107+
$this->assertTrue(StringUtility::isPalindrome('racecar'));
108+
$this->assertFalse(StringUtility::isPalindrome('hello'));
109+
}
110+
}
111+
```
112+
113+
## Code Quality and Linting
114+
115+
The project uses several tools for code quality:
116+
117+
1. **PHPStan**:
118+
```bash
119+
make lint-phpstan
120+
```
121+
122+
2. **Rector**:
123+
```bash
124+
# Check for issues
125+
make lint-rector
126+
127+
# Fix issues automatically
128+
make lint-rector-fix
129+
```
130+
131+
## Development Server
132+
133+
For development and testing of application bridges:
134+
135+
```bash
136+
# Start the development server
137+
make php-dev-server-up
138+
139+
# Stop the development server
140+
make php-dev-server-down
141+
```
142+
143+
## Project Structure
144+
145+
- `src/`: Source code
146+
- `Application/`: Application-related code
147+
- `Core/`: Core functionality
148+
- `Services/`: API services organized by Bitrix24 API scope
149+
- `tests/`: Test code
150+
- `examples/`: Example code demonstrating SDK usage
151+
- `docs/`: Documentation
152+
- `docker/`: Docker configuration
153+
- `tools/`: Development tools
154+
155+
## Additional Resources
156+
157+
- `CHANGELOG.md`: Project changelog
158+
- `CONTRIBUTING.md`: Contribution guidelines
159+
- `README.md`: Project overview
160+
- `SECURITY.md`: Security policy

.php-cs-fixer.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
$finder = Finder::create()
88
->in(__DIR__ . '/src/Infrastructure/Console/Commands/')
9-
->in(__DIR__ . '/src/Services/CRM/VatRates/')
9+
->in(__DIR__ . '/src/Services/CRM/Address/')
10+
->in(__DIR__ . '/src/Services/CRM/Item/Service/')
1011
->in(__DIR__ . '/src/Services/CRM/Contact/')
11-
->in(__DIR__ . '/src/Services/CRM/Requisites/')
12+
->in(__DIR__ . '/src/Services/CRM/Quote/')
13+
->in(__DIR__ . '/src/Services/CRM/Lead/')
14+
->in(__DIR__ . '/src/Services/CRM/Currency/')
1215
->name('*.php')
1316
->exclude(['vendor', 'storage', 'docker', 'docs']) // Exclude directories
1417
->ignoreDotFiles(true)

0 commit comments

Comments
 (0)