<commit_before><?php
/**
 * (c) shopware AG <<EMAIL>>
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ShopwarePlugins\Connect\Tests\Integration\Models;

use Shopware\CustomModels\Connect\Attribute;
use Shopware\CustomModels\Connect\AttributeRepository;
use ShopwarePlugins\Connect\Tests\DatabaseTestCaseTrait;
use Doctrine\DBAL\Connection;

class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase
{
    use DatabaseTestCaseTrait;

    /**
     * @var AttributeRepository
     */
    private $repository;

    /**
     * @var Connection
     */
    private $connection;

    public function setUp()
    {
        $this->repository = Shopware()->Models()->getRepository(Attribute::class);
        $this->connection = Shopware()->Container()->get('dbal_connection');
    }

    public function test_find_source_ids_of_products()
    {
        $this->importFixtures(__DIR__ . '/_fixtures/simple_connect_items.sql');

        $articleIds = $expectedSourceIds = [14467, 14468];
        $this->assertEquals($expectedSourceIds, $this->repository->findSourceIds($articleIds, 1));
    }

    public function test_find_source_ids_of_variants()
    {
        $this->importFixtures(__DIR__ . '/_fixtures/simple_connect_items.sql');

        $articleIds = $mainSourceIds = [14469, 14470];
        $sourceIdsForVariants = [
            '14469-7091849',
            '14470-7091851',
            '14470-7091852',
        ];
        $this->assertEquals($mainSourceIds, $this->repository->findSourceIds($articleIds, 1));
        $this->assertEquals($sourceIdsForVariants, $this->repository->findSourceIds($articleIds, 2));
    }

    public function test_get_local_article_count()
    {
        $this->connection->executeQuery('DELETE FROM s_plugin_connect_items');
        $this->importFixtures(__DIR__ . '/_fixtures/simple_connect_items.sql');
        $count = $this->repository->getLocalArticleCount();
        $this->assertEquals(7, $count);
    }

    public function test_find_all_source_ids()
    {
        $this->connection->executeQuery('DELETE FROM s_plugin_connect_items');
        $this->connection->executeQuery('DELETE FROM s_articles_details');
        $this->importFixtures(__DIR__ . '/_fixtures/simple_connect_items.sql');

        $mainProducts = $this->repository->findAllSourceIds(0, 4);
        $variantIds = $this->repository->findAllSourceIds(4, 3);

        $expectation1 = ['14467', '14468', '14469', '14470'];
        $expectation2 = ['14469-7091849', '14470-7091851', '14470-7091852'];

        $this->assertEquals($expectation1, $mainProducts);
        $this->assertEquals($expectation2, $variantIds);
    }
}<commit_msg>fixed naming in attribute repo test<commit_after><?php
/**
 * (c) shopware AG <<EMAIL>>
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ShopwarePlugins\Connect\Tests\Integration\Models;

use Shopware\CustomModels\Connect\Attribute;
use Shopware\CustomModels\Connect\AttributeRepository;
use ShopwarePlugins\Connect\Tests\DatabaseTestCaseTrait;
use Doctrine\DBAL\Connection;

class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase
{
    use DatabaseTestCaseTrait;

    /**
     * @var AttributeRepository
     */
    private $repository;

    /**
     * @var Connection
     */
    private $connection;

    public function setUp()
    {
        $this->repository = Shopware()->Models()->getRepository(Attribute::class);
        $this->connection = Shopware()->Container()->get('dbal_connection');
    }

    public function test_find_source_ids_of_products()
    {
        $this->importFixtures(__DIR__ . '/_fixtures/simple_connect_items.sql');

        $articleIds = $expectedSourceIds = [14467, 14468];
        $this->assertEquals($expectedSourceIds, $this->repository->findSourceIds($articleIds, 1));
    }

    public function test_find_source_ids_of_variants()
    {
        $this->importFixtures(__DIR__ . '/_fixtures/simple_connect_items.sql');

        $articleIds = $mainSourceIds = [14469, 14470];
        $sourceIdsForVariants = [
            '14469-7091849',
            '14470-7091851',
            '14470-7091852',
        ];
        $this->assertEquals($mainSourceIds, $this->repository->findSourceIds($articleIds, 1));
        $this->assertEquals($sourceIdsForVariants, $this->repository->findSourceIds($articleIds, 2));
    }

    public function test_get_local_article_count()
    {
        $this->connection->executeQuery('DELETE FROM s_plugin_connect_items');
        $this->importFixtures(__DIR__ . '/_fixtures/simple_connect_items.sql');
        $count = $this->repository->getLocalArticleCount();
        $this->assertEquals(7, $count);
    }

    public function test_find_all_source_ids()
    {
        $this->connection->executeQuery('DELETE FROM s_plugin_connect_items');
        $this->connection->executeQuery('DELETE FROM s_articles_details');
        $this->importFixtures(__DIR__ . '/_fixtures/simple_connect_items.sql');

        $mainProductIds = $this->repository->findAllSourceIds(0, 4);
        $variantIds = $this->repository->findAllSourceIds(4, 3);

        $expectedProductIds = ['14467', '14468', '14469', '14470'];
        $expectedVariantIds = ['14469-7091849', '14470-7091851', '14470-7091852'];

        $this->assertEquals($expectedProductIds, $mainProductIds);
        $this->assertEquals($expectedVariantIds, $variantIds);
    }
}
{'fraction_non_alphanumeric': 0.13374411018484958, 'fraction_numerical': 0.04421891989851395, 'mean_word_length': 3.6222780569514237, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4148186', 'n_tokens_mistral': 1751, 'n_tokens_neox': 1574, 'n_words': 261}