<commit_before><?php

class CM_Page_AbstractTest extends CMTest_TestCase {

	public function testGetClassnameByPath() {
		$site = $this->getMockBuilder('CM_Site_Abstract')->setMethods(array('getNamespaces'))->getMock();
		$site->expects($this->any())->method('getNamespaces')->will($this->returnValue(array('Foo', 'Bar')));

		$this->getMockForAbstractClass('CM_Page_Abstract', array(), 'Bar_Page_Test', false);
		$this->assertEquals('Bar_Page_Test', CM_Page_Abstract::getClassnameByPath($site, '/test'));

		$this->getMockForAbstractClass('CM_Page_Abstract', array(), 'Foo_Page_Test', false);
		$this->assertEquals('Foo_Page_Test', CM_Page_Abstract::getClassnameByPath($site, '/test'));
	}

	/**
	 * @expectedException CM_Exception_Invalid
	 * @expectedExceptionMessage page `Test` is not defined in any namespace
	 */
	public function testGetClassnameByPathNotExists() {
		$site = $this->getMockBuilder('CM_Site_Abstract')->setMethods(array('getNamespaces'))->getMock();
		$site->expects($this->any())->method('getNamespaces')->will($this->returnValue(array('FooBar')));

		CM_Page_Abstract::getClassnameByPath($site, '/test');
	}

	public function testGetPath() {
		$this->getMockForAbstractClass('CM_Page_Abstract', array(), 'Test_Page_Foo_Bar_FooBar2', false);
		$this->assertSame('/foo/bar/foo-bar2?foo=1&bar=2', Test_Page_Foo_Bar_FooBar2::getPath(array('foo' => 1, 'bar' => 2)));
		$this->getMockForAbstractClass('CM_Page_Abstract', array(), 'Test_Page_Index', false);
		$this->assertSame('/', Test_Page_Index::getPath());
	}
}<commit_msg>add test<commit_after><?php

class CM_Page_AbstractTest extends CMTest_TestCase {

	public function testGetClassnameByPath() {
		$site = $this->getMockBuilder('CM_Site_Abstract')->setMethods(array('getNamespaces'))->getMock();
		$site->expects($this->any())->method('getNamespaces')->will($this->returnValue(array('Foo', 'Bar')));

		$this->getMockForAbstractClass('CM_Page_Abstract', array(), 'Bar_Page_Test', false);
		$this->assertEquals('Bar_Page_Test', CM_Page_Abstract::getClassnameByPath($site, '/test'));

		$this->getMockForAbstractClass('CM_Page_Abstract', array(), 'Foo_Page_Test', false);
		$this->assertEquals('Foo_Page_Test', CM_Page_Abstract::getClassnameByPath($site, '/test'));
	}

	/**
	 * @expectedException CM_Exception_Invalid
	 * @expectedExceptionMessage page `Test` is not defined in any namespace
	 */
	public function testGetClassnameByPathNotExists() {
		$site = $this->getMockBuilder('CM_Site_Abstract')->setMethods(array('getNamespaces'))->getMock();
		$site->expects($this->any())->method('getNamespaces')->will($this->returnValue(array('FooBar')));

		CM_Page_Abstract::getClassnameByPath($site, '/test');
	}

	public function testGetPath() {
		$this->getMockForAbstractClass('CM_Page_Abstract', array(), 'Test_Page_Foo_Bar_FooBar2', false);
		$this->assertSame('/foo/bar/foo-bar2?foo=1&bar=2', Test_Page_Foo_Bar_FooBar2::getPath(array('foo' => 1, 'bar' => 2)));
		$this->getMockForAbstractClass('CM_Page_Abstract', array(), 'Test_Page_Index', false);
		$this->assertSame('/', Test_Page_Index::getPath());
	}

	public function testGetLayout() {
		$site = $this->getMockBuilder('CM_Site_Abstract')->setMethods(array('getNamespaces'))->getMock();
		$site->expects($this->any())->method('getNamespaces')->will($this->returnValue(array('Foo', 'Bar')));
		/** @var CM_Page_Abstract $page */
		$page = $this->getMockForAbstractClass('CM_Page_Abstract', array(), 'Foo_Page_Test', false);

		$this->getMockForAbstractClass('CM_Layout_Abstract', array(), 'Bar_Layout_Default', false);
		$this->assertEquals('Bar_Layout_Default', get_class($page->getLayout($site)));

		$this->getMockForAbstractClass('CM_Layout_Abstract', array(), 'Foo_Layout_Default', false);
		$this->assertEquals('Foo_Layout_Default', get_class($page->getLayout($site)));
	}

	/**
	 * @expectedException CM_Exception_Invalid
	 * @expectedExceptionMessage layout `Default` is not defined in any namespace
	 */
	public function testGetLayoutNotExists() {
		$site = $this->getMockBuilder('CM_Site_Abstract')->setMethods(array('getNamespaces'))->getMock();
		$site->expects($this->any())->method('getNamespaces')->will($this->returnValue(array('FooBar')));
		/** @var CM_Page_Abstract $page */
		$page = $this->getMockForAbstractClass('CM_Page_Abstract', array(), 'Foo_Page_Test', false);

		$this->assertEquals('Bar_Layout_Default', get_class($page->getLayout($site)));
	}
}
{'fraction_non_alphanumeric': 0.18893173055114537, 'fraction_numerical': 0.0031753232025402587, 'mean_word_length': 8.545454545454545, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 81, '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': '5885806', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1397, 'n_words': 181}