|
1 | 1 | # 🐳 Test-Containers for Quick Magento Development |
2 | 2 | [](https://github.com/EcomDev/testcontainer-magento-data/actions/workflows/docker-images.yml) |
3 | | -[](https://github.com/EcomDev/testcontainer-magento-data/actions/workflows/php-package.yml) |
| 3 | +[](https://github.com/EcomDev/testcontainer-magento-data-php/actions/workflows/php-package.yml) |
| 4 | +[](https://github.com/EcomDev/testcontainer-magento-data-rust/actions/workflows/rust-package.yml) |
4 | 5 |
|
5 | 6 | This package simplifies the process of automated testing with real database and search engine |
6 | 7 |
|
@@ -37,87 +38,11 @@ With the following `IMAGE_NAME` variations: |
37 | 38 | - `mariadb` - Pre-populated MariaDB database container with relevant Magento schema and data |
38 | 39 | - `opensearch` - Pre-populated OpenSearch container with relevant Magento indexes based on db data |
39 | 40 |
|
40 | | -## Usage in PHP |
| 41 | +## Prebuild Packages |
41 | 42 |
|
42 | | -### MySQL container |
43 | | - |
44 | | -Create Latest Magento Database Build |
45 | | -```php |
46 | | -use EcomDev\TestContainers\MagentoData\DbContainerBuilder; |
47 | | - |
48 | | -$container = DbContainerBuilder::mysql() |
49 | | - ->build(); |
50 | | -``` |
51 | | - |
52 | | -Create Latest Magento Database Build with sample data |
53 | | -```php |
54 | | -use EcomDev\TestContainers\MagentoData\DbContainerBuilder; |
55 | | - |
56 | | -$container = DbContainerBuilder::mysql() |
57 | | - ->withSampleData() |
58 | | - ->build(); |
59 | | -``` |
60 | | - |
61 | | -Create 2.4.7-p2 with sample data and fetch number of products |
62 | | -```php |
63 | | -use EcomDev\TestContainers\MagentoData\DbContainerBuilder; |
64 | | -use PDO; |
65 | | - |
66 | | -$container = DbContainerBuilder::mysql() |
67 | | - ->withMagentoVersion('2.4.7-p2') |
68 | | - ->withSampleData() |
69 | | - ->build(); |
70 | | - |
71 | | -$connectionSettings = $container->getConnectionSettings(); |
72 | | -$connection = new PDO( |
73 | | - $connectionSettings->dsn(), |
74 | | - $connectionSettings->user, |
75 | | - $connectionSettings->password |
76 | | -); |
77 | | - |
78 | | -$result = $connection->query('SELECT COUNT(*) FROM catalog_product_entity'); |
79 | | -// Outputs 2040 |
80 | | -echo $result->fetch(PDO::FETCH_COLUMN); |
81 | | -``` |
82 | | - |
83 | | -### MariaDB container |
84 | | -Everything the same as for MySQL container, just a different builder method |
85 | | - |
86 | | -```php |
87 | | -use EcomDev\TestContainers\MagentoData\DbContainerBuilder; |
88 | | - |
89 | | -$container = DbContainerBuilder::mariadb() |
90 | | - ->withMagentoVersion('2.4.7-p2') |
91 | | - ->withSampleData() |
92 | | - ->build(); |
93 | | -``` |
94 | | - |
95 | | -## OpenSearch container |
96 | | - |
97 | | -For OpenSearch container there is a different builder and container, that allows building base url for http connection |
98 | | - |
99 | | -Here is a small example |
100 | | - |
101 | | -```php |
102 | | -use EcomDev\TestContainers\MagentoData\OpenSearchContainerBuilder; |
103 | | -use GuzzleHttp\Client; |
104 | | - |
105 | | -$container = OpenSearchContainerBuilder::new() |
106 | | - ->withSampleData() |
107 | | - ->build(); |
108 | | - |
109 | | -$client = new Client([ |
110 | | - 'base_uri' => $container->getBaseUrl() |
111 | | -]); |
112 | | - |
113 | | -$result = json_decode( |
114 | | - $client->get('magento2_product_1/_count')->getBody()->getContents(), |
115 | | - true |
116 | | -); |
117 | | - |
118 | | -// Outputs 181 |
119 | | -echo $result['count']; |
120 | | -``` |
| 43 | +Packages available in the following languages to streamline usage of the Magento data image: |
| 44 | +- [ecomdev/testcontainers-magento-data](`https://github.com/EcomDev/testcontainer-magento-data-php`) composer package in PHP |
| 45 | +- [testcontainers-magento-data](`https://github.com/EcomDev/testcontainer-magento-data-rust`) cargo crate in Rust |
121 | 46 |
|
122 | 47 | ## 📜 License |
123 | 48 |
|
|
0 commit comments