/** * Method to test getOrphans(). * * @return void * * @covers Windwalker\Language\Language::getOrphans */ public function testGetOrphans() { $this->instance->setDebug(true); // Exists $this->instance->translate('Windwalker Language Test Sakura'); // Not exists $this->instance->translate('Windwalker Language Test No exists flower'); $this->instance->translate('A key not exists'); $orphans = $this->instance->getOrphans(); $this->assertEquals(array('windwalker.language.test.no.exists.flower', 'a.key.not.exists'), array_keys($orphans)); $position = $orphans['a.key.not.exists']['position']; $ref = new \ReflectionMethod($this, __FUNCTION__); $this->assertEquals(__METHOD__, $position['class'] . '::' . $position['function']); $this->assertEquals(__FILE__, $position['file']); $this->assertEquals($ref->getStartLine(), $position['line']); $called = $orphans['a.key.not.exists']['called']; $this->assertEquals('Windwalker\\Language\\Language::translate', $called['class'] . '::' . $called['function']); // Wrap in a function $this->instance->setTraceLevelOffset(1); $this->translate('another.key.not.exists'); $orphans = $this->instance->getOrphans(); $position = $orphans['another.key.not.exists']['position']; $ref = new \ReflectionMethod($this, __FUNCTION__); $this->assertEquals(__METHOD__, $position['class'] . '::' . $position['function']); $this->assertEquals(__FILE__, $position['file']); $this->assertEquals($ref->getStartLine(), $position['line']); $called = $orphans['another.key.not.exists']['called']; $this->assertEquals(__CLASS__ . '::translate', $called['class'] . '::' . $called['function']); }
/** * Method to test getOrphans(). * * @return void * * @covers Windwalker\Language\Language::getOrphans */ public function testGetOrphans() { $this->instance->setDebug(true); // Exists $this->instance->translate('Windwalker Language Test Sakura'); // Not exists $this->instance->translate('Windwalker Language Test No exists flower'); $this->instance->translate('A key not exists'); $orphans = $this->instance->getOrphans(); $this->assertEquals(array('windwalker.language.test.no.exists.flower', 'a.key.not.exists'), $orphans); }