Пример #1
0
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
class my_lime_test extends lime_test
{
    public function arrays_are_equal($a, $b, $message)
    {
        sort($a);
        sort($b);
        return $this->is($a, $b, $message);
    }
}
$t = new my_lime_test(38);
require_once $_test_dir . '/../lib/util/sfFinder.class.php';
$fixtureDir = dirname(__FILE__) . '/fixtures/finder';
$phpFiles = array('dir1/dir2/file21.php', 'dir1/file12.php');
$txtFiles = array('FILE5.txt', 'file2.txt');
$regexpFiles = array('dir1/dir2/file21.php', 'dir1/dir2/file22', 'dir1/dir2/file23', 'dir1/dir2/file24', 'file2.txt');
$regexpWithModifierFiles = array('dir1/dir2/file21.php', 'dir1/dir2/file22', 'dir1/dir2/file23', 'dir1/dir2/file24', 'FILE5.txt', 'file2.txt');
$allFiles = array('dir1/dir2/dir3/file31', 'dir1/dir2/dir4/file41', 'dir1/dir2/file21.php', 'dir1/dir2/file22', 'dir1/dir2/file23', 'dir1/dir2/file24', 'dir1/file11', 'dir1/file12.php', 'dir1/file13', 'file1', 'FILE5.txt', 'file2.txt');
$minDepth1Files = array('dir1/dir2/dir3/file31', 'dir1/dir2/dir4/file41', 'dir1/dir2/file21.php', 'dir1/dir2/file22', 'dir1/dir2/file23', 'dir1/dir2/file24', 'dir1/file11', 'dir1/file12.php', 'dir1/file13');
$maxDepth2Files = array('dir1/dir2/file21.php', 'dir1/dir2/file22', 'dir1/dir2/file23', 'dir1/dir2/file24', 'dir1/file11', 'dir1/file12.php', 'dir1/file13', 'file1', 'FILE5.txt', 'file2.txt');
$anyWithoutDir2 = array('dir1', 'dir1/dir2', 'dir1/file11', 'dir1/file12.php', 'dir1/file13', 'file1', 'FILE5.txt', 'file2.txt');
// ::type()
$t->diag('::type()');
$finder = sfFinder::type('file');
$t->ok($finder instanceof sfFinder, '::type() returns a sfFinder instance');
$t->is($finder->get_type(), 'file', '::type() takes a file, dir, or any as its first argument');
        $nb_lines = count($array_exp1);
        for ($i = 0; $i < $nb_lines; $i++) {
            if (!$array_exp1[$i]) {
                continue;
            }
            // Skip blank lines to avoid testing nothing
            $this->is(trim($array_exp1[$i]), trim($array_exp2[$i]), sprintf('Line %d matches %s', $i, $array_exp1[$i]));
        }
    }
}
require_once SF_DIR . 'test/bootstrap/unit.php';
require_once dirname(__FILE__) . '/../../lib/addon/sfPropelDatabaseSchema.class.php';
require_once SF_DIR . 'lib/util/sfInflector.class.php';
require_once SF_DIR . 'lib/util/sfToolkit.class.php';
require_once SF_DIR . 'lib/yaml/sfYaml.php';
$t = new my_lime_test(409);
$t->diag('Classical YAML to XML conversion');
$p = new sfPropelDatabaseSchema();
$p->loadYAML(dirname(__FILE__) . '/fixtures/schema.yml');
$target = file_get_contents(dirname(__FILE__) . '/fixtures/schema.xml');
$t->is_line_by_line($p->asXML(), $target);
$t->diag('New YAML to XML conversion');
$p = new sfPropelDatabaseSchema();
$p->loadYAML(dirname(__FILE__) . '/fixtures/new_schema.yml');
$target = file_get_contents(dirname(__FILE__) . '/fixtures/schema.xml');
$t->is_line_by_line($p->asXML(), $target);
$t->diag('New YAML to Old YAML conversion');
$old_yml_target = sfYaml::load(dirname(__FILE__) . '/fixtures/schema.yml');
$p = new sfPropelDatabaseSchema();
$new_yml_transformed = $p->convertNewToOldYaml(sfYaml::load(dirname(__FILE__) . '/fixtures/new_schema.yml'));
$t->is_array_explicit($new_yml_transformed, $old_yml_target);
Пример #3
0
    //$thmb->save($result.'.jpg');
    //checkResult($t, 150, 150, 'image/jpeg');
    $t->diag('creates inflated thumbnail');
    $thmb = new sfThumbnail(200, 200, false, true, 75, $adapter, array());
    $thmb->loadFile($data['image/gif']);
    $thmb->save($result . '.gif');
    checkResult($t, 200, 200, 'image/gif');
    $t->diag('creates image from string');
    $thmb = new sfThumbnail(200, 200, false, true, 75, $adapter, array());
    $blob = file_get_contents($data['blob']);
    $thmb->loadData($blob, 'image/jpeg');
    $thmb->save($result . '.jpg', 'image/jpeg');
    checkResult($t, 200, 200, 'image/jpeg');
    // imagemagick-specific tests
    if ($adapter == 'sfImageMagickAdapter') {
        $t = new my_lime_test($tests_imagemagick, new lime_output_color());
        $t->diag('creates thumbnail from pdf', $adapter);
        $thmb = new sfThumbnail(150, 150, true, true, 75, $adapter, array('extract' => 1));
        $thmb->loadFile($data['document/pdf']);
        $thmb->save($result . '.jpg');
        checkResult($t, 150, 116, 'image/jpeg');
    }
}
function checkResult($t, $width, $height, $mime)
{
    global $mimeMap;
    $result = getResultPath();
    $result .= '.' . $mimeMap[$mime];
    // check generated thumbnail for expected results
    // use getimagesize() when possible, otherwise use 'identify'
    $imgData = @getimagesize($result);