<commit_before><?php
use Nathalie\Exam16\DatabaseConnection;
use Nathalie\Exam16\ProductsRepo;

/**
 * Class ProductsTest
 */
class ProductsTest extends PHPUnit_Framework_TestCase
{
    private $database;

    public function setUp()
    {
        $databaseConnection = new DatabaseConnection();
        $this->database     = $databaseConnection->connect();
    }

    public function testGetById()
    {
        $productsRepo = new ProductsRepo($this->database);
        $products     = $productsRepo->getById(1);

        $this->assertEquals('The Trump', $products->Product_Title);
    }

    public function testGetAll()
    {
        $productsRepo = new ProductsRepo($this->database);
        $all          = $productsRepo->getAll();

        $this->assertEquals(5, count($all));
    }

    public function testGetByRestriction()
    {
        $productsRepo = new ProductsRepo($this->database);
        $restriction  = $productsRepo->getByRestriction('vegan');

        $this->assertEquals(1, count($restriction));
    }
    public function testGetByCategory()
    {
        $productsRepo = new ProductsRepo($this->database);
        $category  = $productsRepo->getByCategory('food');

        $this->assertEquals(3, count($category));
    }
}<commit_msg>Included database dump<commit_after><?php
use Nathalie\Exam16\DatabaseConnection;
use Nathalie\Exam16\ProductsRepo;

/**
 * Class ProductsTest
 */
class ProductsTest extends PHPUnit_Framework_TestCase
{
    private $database;

    public function setUp()
    {
        $databaseConnection = new DatabaseConnection();
        $this->database     = $databaseConnection->connect();
    }

    public function testGetById()
    {
        $productsRepo = new ProductsRepo($this->database);
        $products     = $productsRepo->getById(1);

        $this->assertEquals('The Trump', $products->Product_Title);
    }

    public function testGetAll()
    {
        $productsRepo = new ProductsRepo($this->database);
        $all          = $productsRepo->getAll();

        $this->assertEquals(5, count($all));
    }

    /**
     * @return array
     */
    public function dataRestrictions()
    {
        return [
            'Vegan'       => ['Vegan', 1],
            'Vegetarian'  => ['Vegetarian', 1],
            'Normal'      => ['Normal', 3],
            'Pescetarian' => ['Pescetarian', 0],
        ];
    }

    /**
     * @dataProvider dataRestrictions
     *
     * @param $restriction
     * @param $quantity
     */
    public function testGetByRestriction($restriction, $quantity)
    {
        $productsRepo = new ProductsRepo($this->database);
        $products     = $productsRepo->getByRestriction($restriction);

        $this->assertEquals($quantity, count($products));

        foreach ($products as $product)
        {
            $this->assertEquals($restriction, $product->Product_Restriction);
        }
    }

    /**
     * @return array
     */
    public function dataCategory()
    {
        return [
            'Food'  => ['Food', 3],
            'Drink' => ['Drink', 1],
            'Menue' => ['Menue', 1],
        ];
    }

    /**
     * @param $category
     * @param $quantity
     * @dataProvider dataCategory
     */
    public function testGetByCategory($category, $quantity)
    {
        $productsRepo = new ProductsRepo($this->database);
        $products     = $productsRepo->getByCategory($category);

        $this->assertEquals($quantity, count($products));

        foreach ($products as $product)
        {
            $this->assertEquals($category, $product->Product_Category);
        }
    }
}
{'fraction_non_alphanumeric': 0.1380172174396001, 'fraction_numerical': 0.00583171341294085, 'mean_word_length': 2.4207027540360873, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, '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': '624449', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1008, 'n_words': 185}