<commit_before><commit_msg>Added unit tests for EndIfNode.<commit_after><?php

/*
* This file is part of Spoon Library.
*
* (c) <NAME> <<EMAIL>>
*
* For the full copyright and license information, please view the license
* file that was distributed with this source code.
*/

namespace Spoon\Template\Tests;
use Spoon\Template\Autoloader;
use Spoon\Template\Writer;
use Spoon\Template\TokenStream;
use Spoon\Template\Token;
use Spoon\Template\Environment;
use Spoon\Template\Parser\EndIfNode;

require_once realpath(dirname(__FILE__) . '/../') . '/Autoloader.php';
require_once 'PHPUnit/Framework/TestCase.php';

class EndIfNodeTest extends \PHPUnit_Framework_TestCase
{
	/**
	 * @var Spoon\Template\Parser\EndIfNode
	 */
	protected $node;

	/**
	 * @var Spoon\Template\Writer
	 */
	protected $writer;

	public function setUp()
	{
		Autoloader::register();
		$this->writer = new Writer();

		// {endif}
		$stream = new TokenStream(
			array(
				new Token(Token::BLOCK_START, null, 1),
				new Token(Token::NAME, 'endif', 1),
				new Token(Token::BLOCK_END, null, 1)
			)
		);
		$this->node = new EndIfNode($stream, new Environment());
	}

	public function tearDown()
	{
		$this->writer = null;
		$this->node = null;
	}

	public function testCompile()
	{
		$this->writer->indent();

		$this->node->compile($this->writer);
		$this->assertEquals(
			"// line 1\nendif;\n",
			$this->writer->getSource()
		);
	}
}
{'fraction_non_alphanumeric': 0.15531914893617021, 'fraction_numerical': 0.0028368794326241137, 'mean_word_length': 3.9858657243816253, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, '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': '2606715', 'n_tokens_mistral': 516, 'n_tokens_neox': 472, 'n_words': 110}