Skip to content

Commit

Permalink
chore: fix links in README
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanChepurnyi committed Jan 7, 2025
1 parent aafc109 commit 8d0e65a
Showing 1 changed file with 6 additions and 81 deletions.
87 changes: 6 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 🐳 Test-Containers for Quick Magento Development
[![Docker Build](https://github.com/EcomDev/testcontainer-magento-data/actions/workflows/docker-images.yml/badge.svg)](https://github.com/EcomDev/testcontainer-magento-data/actions/workflows/docker-images.yml)
[![PHP Package](https://github.com/EcomDev/testcontainer-magento-data/actions/workflows/php-package.yml/badge.svg)](https://github.com/EcomDev/testcontainer-magento-data/actions/workflows/php-package.yml)
[![PHP Package](https://github.com/EcomDev/testcontainer-magento-data-php/actions/workflows/php-package.yml/badge.svg)](https://github.com/EcomDev/testcontainer-magento-data-php/actions/workflows/php-package.yml)
[![Rust Package](https://github.com/EcomDev/testcontainer-magento-data-rust/actions/workflows/rust-package.yml/badge.svg)](https://github.com/EcomDev/testcontainer-magento-data-rust/actions/workflows/rust-package.yml)

This package simplifies the process of automated testing with real database and search engine

Expand Down Expand Up @@ -37,87 +38,11 @@ With the following `IMAGE_NAME` variations:
- `mariadb` - Pre-populated MariaDB database container with relevant Magento schema and data
- `opensearch` - Pre-populated OpenSearch container with relevant Magento indexes based on db data

## Usage in PHP
## Prebuild Packages

### MySQL container

Create Latest Magento Database Build
```php
use EcomDev\TestContainers\MagentoData\DbContainerBuilder;

$container = DbContainerBuilder::mysql()
->build();
```

Create Latest Magento Database Build with sample data
```php
use EcomDev\TestContainers\MagentoData\DbContainerBuilder;

$container = DbContainerBuilder::mysql()
->withSampleData()
->build();
```

Create 2.4.7-p2 with sample data and fetch number of products
```php
use EcomDev\TestContainers\MagentoData\DbContainerBuilder;
use PDO;

$container = DbContainerBuilder::mysql()
->withMagentoVersion('2.4.7-p2')
->withSampleData()
->build();

$connectionSettings = $container->getConnectionSettings();
$connection = new PDO(
$connectionSettings->dsn(),
$connectionSettings->user,
$connectionSettings->password
);

$result = $connection->query('SELECT COUNT(*) FROM catalog_product_entity');
// Outputs 2040
echo $result->fetch(PDO::FETCH_COLUMN);
```

### MariaDB container
Everything the same as for MySQL container, just a different builder method

```php
use EcomDev\TestContainers\MagentoData\DbContainerBuilder;

$container = DbContainerBuilder::mariadb()
->withMagentoVersion('2.4.7-p2')
->withSampleData()
->build();
```

## OpenSearch container

For OpenSearch container there is a different builder and container, that allows building base url for http connection

Here is a small example

```php
use EcomDev\TestContainers\MagentoData\OpenSearchContainerBuilder;
use GuzzleHttp\Client;

$container = OpenSearchContainerBuilder::new()
->withSampleData()
->build();

$client = new Client([
'base_uri' => $container->getBaseUrl()
]);

$result = json_decode(
$client->get('magento2_product_1/_count')->getBody()->getContents(),
true
);

// Outputs 181
echo $result['count'];
```
Packages available in the following languages to streamline usage of the Magento data image:
- [ecomdev/testcontainers-magento-data](`https://github.com/EcomDev/testcontainer-magento-data-php`) composer package in PHP
- [testcontainers-magento-data](`https://github.com/EcomDev/testcontainer-magento-data-rust`) cargo crate in Rust

## 📜 License

Expand Down

0 comments on commit 8d0e65a

Please sign in to comment.