Ejemplo n.º 1
0
 function testCropHeight()
 {
     $arch = TestTimberImage::copyTestImage('arch.jpg');
     $resized = TimberImageHelper::resize($arch, false, 250);
     $resized = str_replace('http://example.org', '', $resized);
     $resized = TimberUrlHelper::url_to_file_system($resized);
     $is_sized = TestTimberImage::checkSize($resized, 375, 250);
     $this->assertTrue($is_sized);
 }
Ejemplo n.º 2
0
 function testWPMLurlLocal()
 {
     // this test replicates the url issue caused by the WPML language identifier in the url
     // However, WPML can't be installed with composer so this test mocks the WPML plugin
     // WPML uses a filter to alter the home_url
     $home_url_filter = function ($url) {
         return $url . '/en';
     };
     add_filter('home_url', $home_url_filter, -10, 4);
     // test with a local and external file
     $img = 'arch.jpg';
     $img = TestTimberImage::copyTestImage($img);
     $resized = TimberImageHelper::resize($img, 50, 50);
     // make sure the base url has not been duplicated (https://github.com/timber/timber/issues/405)
     $this->assertLessThanOrEqual(1, substr_count($resized, 'example.org'));
     // make sure the image has been resized
     $resized = TimberUrlHelper::url_to_file_system($resized);
     $this->assertTrue(TestTimberImage::checkSize($resized, 50, 50), 'image should be resized');
 }