public function test_mark_item_as_title() { $crawler = $this->client->request('GET', 'http://www.bettycrocker.com/recipes/banana-peanut-butter-and-marshmallow-poke-cake/5e2b9f28-7d7e-4ce2-af66-6a958d47046c'); $filtered = $crawler->filter('.recipePartIngredientGroup h2, .recipePartIngredientGroup dl'); $config = ['locations' => ['_text']]; // There will be some wacky spacing so we need to normalize as well. $normalizer = new NormalizerStack(); $normalizer->push(new EndOfLine()); $normalizer->push(new SingleLine()); $normalizer->push(new Space()); $this->assertEquals(['%%TITLE%% Cake %%TITLE%%', '1 box Betty Crocker™ SuperMoist™ yellow cake mix', '1 cup mashed very ripe bananas (2 medium)', '1/2 cup water', '1/3 cup vegetable oil', '4 eggs', '%%TITLE%% Filling %%TITLE%%', '1 box (6-serving size) vanilla instant pudding and pie filling mix', '3 cups cold milk', '1/3 cup creamy peanut butter', '%%TITLE%% Topping %%TITLE%%', '1 jar (7 oz) marshmallow creme', '1 cup butter, softened', '2 cups powdered sugar', '1/3 cup creamy peanut butter', 'Sliced bananas'], $normalizer->normalize($this->formatter->format($filtered, $config))); }
public function test_mark_item_as_title() { $crawler = $this->client->request('GET', 'http://www.bettycrocker.com/recipes/banana-peanut-butter-and-marshmallow-poke-cake/5e2b9f28-7d7e-4ce2-af66-6a958d47046c'); $filtered = $crawler->filter('.recipePartIngredientGroup h2, .recipePartIngredientGroup dl'); $config = ['locations' => ['_text']]; // There will be some wacky spacing so we need to normalize as well. $normalizer = new NormalizerStack(); $normalizer->push(new EndOfLine()); $normalizer->push(new SingleLine()); $normalizer->push(new Space()); $this->assertEquals(['%%TITLE%%Cake%%TITLE%%'], $normalizer->normalize($this->formatter->format($filtered, $config))); }
protected function instantiateConfigValues() { foreach ($this->config as $key => $value) { // @todo Verify formatter is string? $this->config[$key]['formatter'] = new $this->config[$key]['formatter'](); $normalStack = new NormalizerStack(); foreach ($this->config[$key]['normalizers'] as $normalizer) { // @todo Verify normalizers are all strings? $normalStack->push(new $normalizer()); } $this->config[$key]['normalizers'] = $normalStack; // @todo Verify transformer is string? $this->config[$key]['transformer'] = new $this->config[$key]['transformer'](); } }