/** * TransifexShell::_languages() * * @return array */ protected function _languages() { $translations = $this->Transifex->getProject(); if (!isset($translations['teams'])) { return $this->error('No such project'); } sort($translations['teams']); return $translations['teams']; }
/** * @return void */ public function testPutTranslations() { $file = Plugin::path('Transifex') . 'tests/test_files/test.pot'; $this->assertTrue(is_file($file)); $resource = 'foo'; $this->Transifex = $this->getMock('Transifex\\Lib\\TransifexLib', ['_post'], [$this->Transifex->settings]); $mockedResponse = ['strings_added' => 0, 'strings_updated' => 0, 'strings_delete' => 0]; $this->Transifex->expects($this->any())->method('_post')->will($this->returnValue($mockedResponse)); $result = $this->Transifex->putTranslations($resource, 'de', $file); $this->assertSame($mockedResponse, $result); }
/** * @param string $url * @param mixed $data * @param string $requestType * @return mixed * @author Gustav Wellner Bou <*****@*****.**> */ protected function _post($url, $data, $requestType = 'POST') { $slug = Text::insert($url, $this->settings, ['before' => '{', 'after' => '}']); $slug = str_replace(static::BASE_URL, '', $slug); $slug = strtolower($requestType) . '_' . Inflector::slug($slug) . '_' . md5($data); $file = Plugin::path('Transifex') . 'tests/test_files/json/' . $slug . '.json'; if (!$this->settings['debug'] && file_exists($file)) { $content = file_get_contents($file); return json_decode($content, true); } $result = parent::_post($url, $data, $requestType); if ($this->settings['debug']) { $file = Plugin::path('Transifex') . 'tests/test_files/json/' . $slug . '.json'; file_put_contents($file, json_encode($result, JSON_OPTIONS)); } return $result; }